1. What is Ajax
2. Why use it
- Ajax lightens the burden on the server. The principle of AJAX is “get data on demand”, which can reduce the redundant requests and the burden of the server.
- Better user experience
- We can transfer the burden of the previous server to the client, use the idle capacity of the client to deal with, reduce the burden of the server, make full use of bandwidth resources, save space and broadband rental costs.
- External data can be called
- Based on standardized and widely supported technology, there is no need to download plug-ins or applets.
- Further promote the separation of page presentation and data
3. Ajax application scenarios
Scenario 1: data validation
Scenario 2: data on demand
Scenario 3: automatically update the page
4. AJAX development framework
- DWR(Direct Web Remoting)
Cache query results
Free use of source code
Accessing and returning data using the htmlcontrols component
The page does not need to be overloaded, using event proxy (data access layer)
Because only one calling interface method is provided, the server CPU is very small.
The application configuration is simple and easy to use;
Ajax function can be realized with only one Ajax shell. Just put the control that needs no brush into Ajax shell.
Ajax function and common postback can coexist in one webform. Magic Ajax processing module only deals with the callback action of the control contained in Ajax protocol.
The content of viewstate is visible to postback and callback. Therefore, both viewstate generated by callback and postback are visible;
Provide an event model similar to postback callpack
Support IE and Firefox
Compared with traditional Ajax technology, Anthem.NET It has the following advantages:
It doesn’t need any technology upgrade. People who don’t use ajax technology before can realize asynchronous interaction according to the previous programming method;
support asp.net 1.1 and asp.net two
5. Ajax Pro description
This document will use AjaxPro.Net Framework to achieve Ajax function: call the server method asynchronously on the client side. AjaxPro.Net Is an excellent. Net environment Ajax framework, the usage is very simple, you can refer to the relevant information, This document describes several key points of using Ajax pro with a simple example. This example implements a simple function. The server returns the result of adding 1 to the number entered in the page to the client (note that there must be an Ajax Pro package, that is AjaxPro.dll File, which can be downloaded from VSS).
6. An example of Ajax Pro
6.1. Add AjaxPro.dll application
2.1.1 open the project with vs. in its resource manager, right-click reference and left-click “Add Reference”, as shown in Figure 1_ 1
2.1.2 as shown in Figure 1_ 2, click Browse to find AjaxPro.dll Where the file is, double-click AjaxPro.dll , and then click OK.
2.1.3 in the reference folder of the resource manager, you can see Ajax pro, which indicates that the reference is added successfully, as shown in Figure 1_ 3.
2.2 configuration web.config
The purpose of this step is to ensure that the client’s requests (post and get) to “ajaxpro / *. Ashx” are all processed AjaxPro.AjaxHandlerFactory Intercept.
open web.config File in < configuration >< system.web >Add the following code after,
As shown in Figure 2_ 1.
2.3. Add server method
2.3.1 open the background code and open the_ Add the following code to the load method,
AjaxPro.Utility.RegisterTypeForAjax (typeof (the class name of the class in which it belongs));
As shown in Figure 3-1.
Its function is to output the following code to the client:
2.3.2 to add a number plus one, first add one before the method[ AjaxPro.AjaxMethod ]Then write the method like the C # method, as shown in Figure 3-2
Note: need to add[ Ajax.AjaxMethod ]Identification, so that it can be accessed by the client
2.4 add foreground code
Add JS script in the foreground and call the server-side method, as shown in Figure 4-1（ Try.AjaxTest.Add (Num), try is the page class, that is, the namespace of the Ajax test class, here is try; Ajax test is the class name, and add is the method name)
2.5 operation procedure and inspection results
According to the above four steps, the expected effect can be achieved, as shown in Figure 5-1.
AjaxPro.dll Resource download address:http://xiazai.jb51.net/202007/yuanma/AjaxPro_jb51.rar
Here is a brief introduction to this article AjaxPro.dll , asp.net Front JS calls the background method of the article introduced to this, more related AjaxPro.dll , asp.net Front JS call background content, please search previous articles of developer or continue to browse the following related articles, I hope you can support developer more in the future!