Use of ajaxpro (Ajax architecture) in ASP. NET

Source: Internet
Author: User

1. First download the ajaxpro component. And reference ajaxpro. DLL to the website (or project ).

2. modify web. config. In<System. Web>Add the followingCode.

 
<Configuration>
<System. Web>
<Httphandlers>
<! -- Register the Ajax Handler -->
<Add verb = "post, get" Path = "ajax/*. ashx" type = "Ajax. pagehandlerfactory, Ajax"/>
</Httphandlers>
</System. Web>
</Configuration>


 
3. Register ajaxpro during the page_load event on the page. For example:
 
Protected void page_load (Object sender, eventargs E)
{
Ajaxpro. Utility. registertypeforajax (typeof (_ default); // The _ default parameter indicates the page.
Class Name. If it is placed in a namespace, you must enter the complete namespace (for example, namespaces. _ default)
}
 
4. Create a server method. If you add the [ajaxpro. ajaxmethod] tag to a method,
the method becomes a method that can be called by ajaxpro for shadow.
[ajaxpro. ajaxmethod]
Public String getvalue (int A, int B)
{< br> // This method is used to input two numbers from the client, return to the client after adding computing on the server side.
return convert. tostring (a + B);
}
5. Client call.
<Script language = "JavaScript">
Function getvalue (){
_ Default. getvalue (, getgroups_callback); // call the _ default. getvalue method on the server.
This requires a callback function to receive the client result after the server completes processing.
Form1.textbox1. value = "123 ";
}

// The user accepts and processes the results returned by the server.
Function getgroups_callback (response ){
VaR dt = response. value;
Alert (DT );
}
</SCRIPT>


 
This is simple, but it is already a complete ajaxpro.
 
Of course, ajaxpro can provide many more practical and powerful functions. This is just an example. Sort the other files in another day and try again.
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.