What is Page Method and How to use it

JQuery Logo

JQuery Logo

I don’t know have you ever needed to use a server side method in a client (JavaScript or JQuery) function or not? PageMethod is the answer for this question. Actually PageMethod is not a complicated method it is just a simple method with 2 differences.

  1. All Web Methods should be Static
  2. And you need to add a [WebMethod] attribute to the top of method
public static void GetMyData()
// your codes …

And that’s all. Your WebMethod is ready to use in client scripts. The good news is that you can use these methods in both of Web Services and Asp.NET Ajax.
How to Use WebMethods in Client Side Scripts? Or How to call a server-side method in JQuery functions?

function SendForm() {
PageMethods. GetMyData ();

Where this kind of methods can be useful?

Just think that you have a web application which needs keyboard short-cuts to be enabled. Or an Ajax modal which try to pass some data to other server methods and some other examples.

You can find a good article about it here