Friends who have used the new function Call Back in ASP.NET 2.0 may find it troublesome to create an additional Web Services (.asmx) page. If you think it is too troublesome to create an additional .asmx Web Services page, you can also There is an easier way to make asynchronous calls, which we call Page Method.
You can create an .aspx page and arrange the ScriptManager, TextBox and Html Button in the same way:
Then we type the following code:
Next, please test the running results. You will find that it can be called asynchronously (you can use server-side information to update the TextBox content without changing the page after pressing the Button), but there is no need to create an additional .asmx file. The structure of the program is a little cleaner. This is how PageMethod is used. Please note that the PageMethod of .aspx must be declared as a static method (plus the shared keyword), and the following Attribute (lines 1-2) is added:
At the same time, the ScriptManager control on the .aspx page must set its EnablePageMethods property to true to use PageMethod correctly .