Scheps in web applications

zhaozj2021-02-16  45

Scheps in web applications

Julien Cheysial Writing in 2003/10/01

JOISE.LI translated and modified in 2004-4-2

Written in front:

The original article is an article I have found when I need the progress bar, explain the details and accompany them. I added my own modification on the basis of the original text: increase the thread tension and put the use of the progress bar in the sub-thread. This is my first translation article, please refer to you. In the original text, please contact the reference.

Who said that the progress bar can not be used in a web application? I think it can be. This article introduces the quality and interface friendship of the web application by using progress bar during processing ends. In fact, if a web application has been running in a stateless and no connection, it is easy to think that things have been over. But this article describes the progress bar that does not use any ActiveX control and a messy java applets will help improve this.

The key to the use of progress bar in a web application is that the browser has the ability to display the page before all pages are loaded. We will use this characteristic to generate steps and send a page to the client. First, we will use HTML to generate a perfect and beautiful schedule, then we dynamically send JavaScript blocks to update the progress bar. Of course, all the above content is implemented before disconnecting the user request. In C #, Response.Write allows us to join custom content to the cache and response.fluse () allows us to send content in all cache zones to the user's browser.

first step:

The first step allows us to create a progress bar, we use ProgressBar.aspx. As mentioned above, we gradually generate and send a page to the client. First, we will use HTML to generate a perfect and beautiful progress bar. The required HTML code can be obtained in the progravelbar.htm in the first defined, so the first thing is to load it and send the data stream to the client's browser, add the following lines in Page_LOAD of ProgressBar.aspx:

String strfilename = path.comBBine (Server.mAppath ("./ include"), "progressbar.htm");

StreamReader SR = New StreamReader (StrfileName, System.Text.Encoding.default);

String strHtml = sr.readtoend ();

Response.write (strHTML);

sr.close ();

Response.flush ();

The following is the HTML code of ProgressBar.htm, (Translation: The author puts the script function in another JS file, but I am still in this static page)