asp.net ajax client Programming Trip (vii)--The remaining questions (end article)

Source: Internet
Author: User

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

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.