Page Methods are functions in the code-behind file for an ASP.net WebForms page that can be invoked from Web Services or AJAX. They are decorated with the [WebMethod] attribute and marked with the static keyword (Shared in VB.NET).
A Page Method is a function in the code-behind file for an ASP.net WebForms page that can be invoked from Web Services or AJAX. They are somewhat similar to to JsonResult
methods in ASP.net MVC.
Page Methods can be easily recognized by the presence of the [WebMethod]
attribute and the static
keyword (or Shared
in VB.NET).
These methods can be used in Web Services or AJAX.
Since these are static
/ Shared
method, they cannot refer to any instance data from the page. In particular, they cannot refer to the controls on the page.
In fact, since an instance of the page only exists during a HTTP request to the page, there is no instance available while the page method is running.