Hi I am calling a simple page method from javascript , here is my code at markup
function OnCallSumComplete(result, userContext, methodName) {
alert(result);
}
function OnCallSumError(error, userContext, methodName) {
if (error !== null) {
alert(error.get_message());
}
}
function test(){
var contextArray = "";
PageMethods.TestMethod("test parameter", OnCallSumComplete, OnCallSumError, contextArray);
}
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
at cs
[System.Web.Services.WebMethod]
public static string TestMethod(string para)
{
return "Yes this is working";
}
the alert show the result and it says "null". I check firebug and i don't see error from console.
If i change the TestMethod to
[System.Web.Services.WebMethod]
public static string TestMethod()
{
return "Yes this is working";
}
And PageMethod to
PageMethods.TestMethod( function (response) { alert(response); } );
It shows the correct response as "Yes this is working". However, i need to pass parameter to the function. Do i miss anything?
Thanks for help.