Call non-synchronous PageMethod in ASP. NET AJAX

Source: Internet
Author: User

ASP. NET 2.0 new features Call Back may be troublesome, but you need to create another Web Sevices (. asmx) page. the Web Services page of asmx is too troublesome. There is also a simpler method for non-synchronous calls.Page Method.

You can create a. aspx page and deploy ScriptManager, TextBox, and Html Button in the same way:

 

Then, enter the following code:

 

Then, test the running results and you will find that the same method can be called in non-synchronous mode (after the Button is pressed, the TextBox content can be updated using the server information without changing pages ), however, you do not need to create an additional one. the asmx file is slightly refreshed in the program structure. This is how PageMethod is used. Be sure to declare the. aspx PageMethod as a static method (with the shared keyword) and add the following Attribute (line 1-2 ):

 

For the ScriptManager control on the. aspx page at the same time, you must set its EnablePageMethods attribute to true to use PageMethod correctly.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.