The progress bar in the Web| program Web application
Julien cheyssial Writing in 2003/10/01
Joise.li translated and modified in 2004-4-2
Written in front:
The original is an article I found when I needed to use the progress bar to explain the details and attach an example. I added my own modifications on the basis of the original text: increased threading and the use of the progress bar in the child threading process. This is the first time I have translated the article, please correct me. The original text is found in http://www.myblogroll.com/Articles/progressbar/, please refer to.
Who says you can't use a progress bar in a Web application? I think I can. This article describes how to improve the quality and interface friendliness of Web applications by using the progress bar during long service-side processing. In fact, if a Web application is running in a stateless and connectionless state, it is easy for the user to assume that it is over. But the progress bars that are described in this article for not using any ActiveX controls and cluttered Java applets will help improve this.
The key to using the progress bar in a Web application is the ability of the browser to display the page before all the pages are loaded. We will use this feature to generate the steps and send the page to the client. First, we'll use HTML to generate a perfect and beautiful progress bar, and then we'll dynamically send JavaScript blocks to update the progress bar. Of course, all of the above is implemented before a user request is disconnected. In C #, Response.Write allows us to add custom content to the cache and Response.fluse () allows us to send content from all the buffers to the user's browser.
First step:
The first step is to create a progress bar page where we use progressbar.aspx. As mentioned above, we incrementally build and send pages to the client. First, we will use HTML to generate a perfect and beautiful progress bar. The required HTML code can be obtained from the predefined progressbar.htm, so the first thing is to load it and send the data stream to the client's browser, adding the following lines to the progressbar.aspx Page_Load:
Now we can start to update the progress bar, which is a very important part, because it can make your progress bar live. (the original is to use the random increase of 15 times until the loading completed, this article only use from 1-100 of the uniform increase, the following content is not translated)
First we open a new thread and add the following code to the Page_Load:
Thread thread = new Thread (new ThreadStart (ThreadProc));
Note that in the above code we use a for loop that sends a script <SCRIPT>SETPGB (' Pgbmain ', ' {0} ') to the client at the end of each increment of I, and </script>, where {0} is replaced by the corresponding I, The script will invoke the SETPGB JavaScript function to change the progress bar status of the page.
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.