I have multiple page methods in my
base page. Is there a way to tell the
script manager which methods I want
included for the particular page as I
am not using all methods on all pages?
I'm not sure whether this is possible. What I would do then however is to move your methods that are specific to a certain page in the actual page itself rather than in the base page.
What you could do is to use asmx webservices instead of using page methods for accessing server-side logic from JavaScript.
[System.Web.Script.Services.ScriptService]
public class MyWebService
{
[WebMethod]
public string GetData(int id)
{
//do some work
//return result
}
}
In your aspx or ascx code you do the following
function someFunction(){
WebServiceNamespace.MyWebService.GetData(123, onSuccessCallback, onErrorCallback);
}
function onSuccessCallback(result){
//process your result. Usually it is encoded as JSON string
//Sys.Serialization.JavaScriptSerializer.deserialize(...) can be used for deserializing
}
function onErrorCallback(){
//display some info
}
You would have to look on how the returning object of your webservice is encoded. Normally it is encoded as Json. I don't remember now whether this has to be specified explicitly in your web.config.
//Edit:
What I forgot. You can use the asp.net ScriptManager for registering your scripts and web services:
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/scripts/WebServiceScripts.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="~/Services/MyWebService.asmx" />
</Services>
</asp:ScriptManager>