About loading ...
It is believed that friends doing AJAX applications do not use loading, otherwise the network latency will make the user experience very poor, and users will not know that the system is working. So how do you do loading when you are programming with asp.net ajax clients?
Let's first analyze when loading should be shown and when to terminate. A typical asynchronous interaction process is as follows:
1. The user makes a request
2. Network Latency
3. Server-side processing
4. Server Return Data
5. Network Latency
6. Client Rendering Data
During this interaction, the loading should appear after the first step and disappear at the end of step sixth. As you can see from the preceding knowledge, the end of the first step is the end of the event handler function, and the end of step sixth is the end of the callback function. So we found the place where the loading began to end. So how does loading achieve it? My idea is: first place a span or div on the page, which has a loading picture, but at the beginning the span or div is hidden. The loading effect is achieved when loading is made visible at the beginning and loading is not visible when the end is finished. Let's take a look at the example below.
Default.aspx:
1<%@ Page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%>
2
3<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
4
567 <title>untitled page</title>
89<body>
<form id= "Form1" runat= "Server" >
One <asp:scriptmanager id= "ScriptManager1" runat= "Server" >
<Scripts>
<asp:scriptreference assembly= "Microsoft.Web.Preview" name= "Previewscript.js"/>
<asp:scriptreference path= "~/ajax.js"/>
</Scripts>
<Services>
<asp:servicereference path= "~/webservice.asmx"/>
</Services>
</asp:ScriptManager>
<br/>
<span id= "Loading" >
</span>
<br/>
<span id= "Content" >
Num </span>
<br/>
<input id= "Submit" type= "button" value= "Get Content"/>
</form>
30</body>
31