Advantages
·
This approach is easier and the code is shorter and reliable.
·
It provides greater compatibility since it is easy to change
fast.
·
Less work for developer to write client script and a server
method.
·
Page parameters become strongly typed and automatically
validated.
·
You don't have to parse and convert parameters by yourself. In
ASP.NET, parameters passed on URLs are available through Request.QueryString,
only as strings.
·
No need to look at a target page's code to know how to call it.
No need for separate documentation about ways to call a page.
·
Page parameters are automatically validated and become strongly
typed.
·
As we don’t to post entire viewstate of the page using Page
Methods we achieve the bandwidth benefits.
Key Points to Remember
·
The Page Method should be static using the attribute [WebMethod].
·
The Page Method can be in the code behind file of the page and in
aspx file as well.
·
The EnablePageMethods property of the script manger should be
marked as “True”.
·
The call back methods are mandatory to receive the processed
result on the client side.
·
Page Methods don’t support all the datatypes to return to client.
·
We can access the Session. Application and Cache variables using
Page Methods.
References
http://randomactsofcoding.blogspot.com/2007/10/introduction-to-pagemethods.html
http://metasapiens.com/PageMethods/features.aspx
http://blogs.msdn.com/sburke/archive/2006/10/21/hint-components-that-use-web-services-with-asp-net-ajax-v1-0-beta.aspx
http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx
http://blogs.msdn.com/mattgi/archive/2006/11/15/accessing-session-data-from-javascript.aspx