Book Store  
  Contact Us  
  Links  
  Site Map  
Javascript - progress bar

Creating a Progress Bar for use in ASP

 

If you have an ASP script which takes a long time to complete, such as a file upload or server processing, you may want an indication to the user that something is happening.

It is possible to create a simple progress bar using Javascript and incorporate this into an ASP page.

The progress bar runs on the browser client and so does not know how long the processing will take. However, its better than just having a screen which appears to be doing nothing.

If you do have some idea on how long the processing will take, it should not be too difficult to modify the code to indicate the % complete. You will have to calculate the estimated time before you submit.

The files

progressbar.htm is an example file with all the Javascript code to illustrate the methods.

main.htm is a simple htm file which displays the progress bar in a window and can be closed from main.htm.

progressbar.asp together with finish.asp illustrate how to use the progress bar from an ASP page. When you run progressbar.asp you can click on the submit button. This calls the file finish.asp which contains a very long calculation during which time the progress bar will start to increment.

When finish.asp has finished its calculation, it writes back to the client and completes the process.