Show progress when ASP handlers

Source: Internet
Author: User

Friends who have used the software know that the progress bar is an important part of a good software.

Its existence enables the user to master the program's running progress in time, and confirms that the application is working properly. But the ASP does not seem to have the above standard control, control is also more troublesome.

So how to achieve the progress bar?

Here are some of my views (for reference only)

We typically use a page (*.asp) to process or control these programs when using an ASP handler (referring to writing files or manipulating databases), and then jump to the display page when the processing is complete. We can then display the progress bar through these processing pages. The method is to create a progress bar by drawing 100 of the same graphics (such as colored rectangles) in sequence according to the program's processing progress. The effect is similar to that achieved with other programming tools

Here are some source, hoping to give you an inspiration.

Response.buffer=true

Dim lostnum

Dim shownum

Delayshow (Dstep,dmax) process is used to show how many img (Draw how much progress)

Where DMax indicates how many (DMax) steps the entire program needs to handle to complete the handler.

Where Dstep indicates that the current process is the component of the entire process, expressed in quantity.

The existence of variable lostnum is due to dmax (such as 10000), and dstep too small (such as 1). If the call to Delayshow (1,10000) is bound to be impossible to draw an IMG, in fact

Delayshow (100,10000) only to draw once, said to complete 1%, because 100 accounted for 10000 of 1%.

Sub Delayshow (Dstep,dmax)

Dim total//Display screen 100 img

Dim dtemp//Transition variable

total=100

Dtemp=dstep

Dstep=dstep+lostnum

if (dstep*total)/dmax<1 Then

When you want to deal with things that are not even 1%, do not draw img At the same time with variable Lostnum to store the total number of outstanding processing, easy to call this process at the next time processing.

Lostnum=lostnum+dtemp

Else

For Ccc=1 to fix ((dstep*total)/dmax)//Take an integer

Response.Write "

"

Next

Response.Flush//Display the contents of the cache (picture)

Variable shownum is used to store the currently drawn img

Shownum=shownum+fix ((dstep*total)/dmax)

Lostnum=0

End If

End Sub

Due to the problem of the algorithm, the main reason is that it can not be completely painted 100 times, then you need

Process Showlost () The remaining not drawn IMG, all display processing, to achieve the length of the progress bar

Sub Showlost ()

For Ccc=1 to (100-shownum)

Response.Write ("

")

Next

Response.Write "

"

Response.Flush

End Sub

Finally, please note that

Caching technology is needed here

Response.buffer=true;

Response.Flush;

Response.End

Please refer to the MSDN Help

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.