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

2 Responses to What is Page Method and How to use it

  1. Saber Soleymani says:

    Thank you, but it requires ScriptManager…
    I found this article to simulate it using jQuery: http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/

  2. Yes it needs ScriptManager, and I linked your reference in my post before in the last line. you take alook at it. you can check it.
    and thank you for your consideration.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: