What is PageMethod in ASP.Net AJAX?

 Posted by Rajni.Shekhar on 4/11/2012 | Category: ASP.NET AJAX Interview questions | Views: 4390 | Points: 40

PageMethods of ASP.NET AJAX are used to call server side code in client side code. PageMethods are implemented in code behind file. These are public static methods and are annoted with [WebMethod] attribute.


public static string function1(string param1)
return "success";

These page methods are renderd as inline javascript and called by a client side code.

Call function1 using PageMethods in javascript file.


function OnSuccess(val)
//fetch returned value on success.
alert("Succcessfully done.");
return true;

function OnFail()
alert("Some error occurred during called page method: function1.");
return false;

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response