Ajax. dll and ajaxpro. dll usage

Source: Internet
Author: User

Application of ASP. NET ajaxpro

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

2. modify web. config. Add the following to the <system. Web> element:Code.

<Configuration>
<System. Web>
<Httphandlers>
<! -- Register the Ajax Handler -->
<Add verb = "*" Path = "ajaxpro/*. ashx" type = "ajaxpro. ajaxhandlerfactory, ajaxpro"/>
</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 )); // This _ default refers to 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. Add the [ajaxpro. ajaxmethod] tag to a method,
This method becomes a method that ajaxpro can call for shadow. As follows:
[Ajaxpro. ajaxmethod]
Public String getvalue (int A, int B)
{
// This method transfers two numbers from the client and returns them to the client after adding them to the server.

Return convert. tostring (A + B );
}

5. Client call.
<Script language = "javas Other ">
Function getvalue (){

_ Default. getvalue (1, 2, getgroups_callback ); // The _ default. getvalue method of the server is called.
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.


Please note that ajax.net actually has two versions: ajaxpro. dll and Ajax. dll. These two versions are similar in use, but there are still differences. The main differences are as follows:
(1) The web. config configuration file is different.
The configuration file of Ajax. dll is written
<Add verb = "post, get" Path = "ajax/*. ashx" type = "Ajax. pagehandlerfactory, Ajax"/>
The configuration file of ajaxpro. dll is written
<Add verb = "*" Path = "ajaxpro/*. ashx" type = "ajaxpro. ajaxhandlerfactory, ajaxpro"/>

(2) the method for calling server methods is different. For this reason, many friends find that the namespace cannot be found or the object does not reference Ajax. when calling a DLL, do not add a namespace to the server method. Apply ajaxpro. when calling a DLL, you need to add a namespace to call the server method.

For example, when the page is set to this setting 
<% @ Page Language = "C #" codebehind = "test. aspx. cs" autoeventwireup = "false" inherits = "Web. Test" %>

client call method:
Ajax. DLL is
var response = test. getservermethod ();
alert (response. value);

Ajaxpro. dll is 
VaR response = web. Test. getservermethod (); 
Alert (response. value );

 

Source:Http://hi.baidu.com/kylin451771150/blog/item/89b7b3ed9e1d95d2b31cb11d.html

Certificate ---------------------------------------------------------------------------------------------------------------------------------------------



Ajaxpro. dll & JSON. dll

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.