Web progress bar is a user friendly UI factor to web applicaion. In this tutorial, we will show you how to create a web progress bar using ASP.NET 2.0 and C#.NET.

First, to create a WebProgressBar.aspx page and WebProgresssBar.aspx.cs. Then import the System.Web.SessionState, System.Text and System.Threading namespaces.

The System.Web.SessionState namespace supplies classes and interfaces that enable storage of data specific to a single client within a Web application on the server. The session-state data is used to give the client the appearance of a persistent connection with the application. While the System.Threading namespace provides classes and interfaces that enable multithreaded programming.

In order to demo the progress bar clearly, we simulate a long task by using the Thread.Sleep method to block the current thread for the specified number of milliseconds. Each block represent the different state. The session state value will be changed after each block.

The method of showModalDialog is used to create a modal dialog box that displays the specified HTML of progress bar.

Button1_Click event is for starting the threads.

The front WebProgressBar.aspx page looks something like this:

In order to show the progress strip, we created Progress.aspx page. The bar will be refershed based on the session states, therefore, we can show the progress. The code behind page is as follows.

The front progress.aspx page looks something like this:

The whole WebProgressBar.aspx for the code behind page is as follows.

The whole progress.aspx for the code behind page is as follows.

Download Source Files