Click here to Skip to main content
11,432,427 members (59,645 online)
Click here to Skip to main content

Using UpdateProgress and Making Background Inactive

, 9 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
To show 'Please wait' text to the user when a button is clicked and some code block needs to be executed. The background should be made disabled, so that user cannot click on other links/buttons before the current execution completes.


This tip will show how to display a user friendly "Please wait" message on the web-page, when a button on a web page is clicked by the user to initiate a long process like insertion of data to database, fetching a big result set, uploading/downloading files, etc., and to prevent the user from clicking here and there on the page until the current execution completes.


The UpdateProgress control supports in designing a more spontaneous interface when a Web page contains UpdatePanel controls for partial or full page postback. If a partial-page update is wary, you can use the UpdateProgress control to arrange for graphic response about the position of the update. You can put multiple UpdateProgress controls on a page, each associated with a different UpdatePanel control. Alternatively, you can use one UpdateProgress control and associate it with all UpdatePanel controls on the page.

The Ajax UpdateProgress control renders a <div> element which is shown or hidden based on whether an associated UpdatePanel control has caused an asynchronous postback. For initial page load, the UpdateProgress control is not displayed.

Using the Code

Here in the demonstration program, I am using Ajax UpdateProgress control to show Progress Image/Progress bar and display a user message. The background will be made inactive by using CSS.

Follow the below steps:

  1. Add AjaxControlToolkit to your web application, and register the same in your .aspx page.
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
  2. Add a ScriptManager on your .aspx page.
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
  3. Add the below CSS in <Head></Head> tag in .aspx page or in external CSS file (if any).
    position: absolute;
    background-color: #FAFAFA;
    z-index: 2147483647 !important;
    opacity: 0.8;
    overflow: hidden;
    text-align: center; top: 0; left: 0;
    height: 100%;
    width: 100%;
  4. Add UpdateProgress on your page. Provide an Image and a text message in <ProgressTemplate>.

    With DisplayAfter property, you can modify the time after which the message should start displaying. The value should be given in microseconds.

    AssociatedUpdatePanelId is the Id of the update panel which contains the controls causing long running code.

    <asp:UpdateProgress ID="UpdateProgress1" DisplayAfter="10" 
    runat="server" AssociatedUpdatePanelID="upTest">
      <div class="divWaiting">            
    	<asp:Label ID="lblWait" runat="server" 
    	Text=" Please wait... " />
    	<asp:Image ID="imgWait" runat="server" 
    	ImageAlign="Middle" ImageUrl="~/Images/10.gif" />
  5. Provide the controls in UpdatePanel which is associated with UpdateProgress. Whenever any event generated from a control inside associated UpdatePanel, the progress image and message will be shown in the center of screen.
    <asp:UpdatePanel ID="upTest" runat="server">
        <asp:Button ID="btnSubmit" OnClick="btnSubmit_Click" Text="Submit" runat="server" />

If you want to test the above functionality, then use the below code in btnSubmit_Click event handler.

protected void btnSubmit_Click(object sender, EventArgs e)

Points of Interest

UpdateProgress control can be put inside or outside UpdatePanel controls. UpdateProgress control will be displayed whenever the associated UpdatePanel control is updated as a result of an asynchronous postback. This works even if the UpdateProgress control is inside another UpdatePanel control.

To know more about UpdateProgress, please visit:


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
India India
No Biography provided
Follow on   LinkedIn

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150428.2 | Last Updated 9 Oct 2013
Article Copyright 2013 by PoojaGahlaut
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid