Precessing----Please wait message

Posted on 2004-11-19
Last Modified: 2009-08-13
I am querying a database with huge data,which takes time to display the records.Mean while I would like to display message(or image) saying Procesing plz wait.
Question by:kollu
    LVL 18

    Accepted Solution

    LVL 8

    Assisted Solution

    Here's a snippet I threw together.  When the user clicks the button, javascript causes the "Please Wait" message to be visible:

    <script runat="server">
          private void Page_Load(object sender, System.EventArgs e)
                btnSubmit.Attributes.Add("onclick", "document.getElementById('msgWait').style.display='block'");

    <form runat="server">
       <asp:Button id="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" /></p>

    <div id="msgWait" style="display:none; color: red"><p>Please wait.  This may take up to a minute...</p></div>
    LVL 17

    Assisted Solution

    First, create a basic page that asks a user for their name and provides them a button to submit the page. The code behind the button is pretty simple:

    Response.Redirect("EndPage.aspx?name=" & Name.Text)

    Next, create a simple page that sleeps the thread for 10 seconds to simulate a long running process. After the thread wakes up, the page updates a label to welcome the user. The code looks like this:

    Label1.Text = "Welcome " & Request.QueryString("Name") & "!"

    If you run these two pages, you'll find that when you click on the submit button, the browser sits on the start page for 10 seconds without any feedback to the user. Now modify the start-page code to redirect to an intermediary loading page. This page provides your end user with visual notification that the application is processing their request. Here's the new code behind on the submit button:

    Dim URL As String = "EndPage.aspx?name=" & Name.Text
    Response.Redirect("Loading.Aspx?Page=" & URL)

    The previous code now captures the original URL and passes it on the query string to the loading page, Loading.Aspx. The loading page then displays to the user a status message while loading the requested page.
    First, start by creating a basic message for your user:

    <table border="0" cellpadding="0" cellspacing="0"
      width="99%" height="99%" align="center"
              <td align="center" valign="middle">
        <font color="Red" size="5">
          <span id="Message">Loading&nbsp;--
                      Please Wait</span>
          <span id="Progress" style="WIDTH:25px;

    Inside the table at the middle of the screen, you want to display a message to the user. You'll use JavaScript's Progress span tag here to update the screen and inform the user that the application is responding.

    Now that the screen is set up, you need to hook up the JavaScript to make the page work using the client-side onLoad and onUnload events:

    <body onload="BeginPageLoad()" onunload="EndPageLoad()">

    When the page is loaded, your custom BeginPageLoad function is fired. BeginPageLoad has two lines of JavaScript:

    location.href = "<%= Request.QueryString("Page")%>";
    iIntervalId = window.setInterval("iLoopCounter=
      UpdateProgress(iLoopCounter, iMaxLoop)", 500);

    The first line of code starts the loading processes for the requested page. After the page has been requested from the server, a call to the UpdateProgress function starts a timer that updates the screen. This function uses the Progress span tag and displays five dots in succession. When the fifth dot is added, the span is cleared and the process starts over. Once the new page is finished loading, it is rendered immediately for the user and the EndPageLoad function will be processed. The EndPageLoad function then performs some basic clean-up and notifies the user if the transfer fails or an error occurs:

    Progress.innerText = "Page Loaded -- Not Transferring";

    As you can see, you need only a few lines of JavaScript to provide the user with visual notification that their request has been submitted and is being processed. By providing the user with this feedback, you can help eliminate the possibility that the user will cancel the page request and attempt to resubmit the page or hit the submit button repeatedly, possibly corrupting your data or bringing down the application.


    Expert Comment

    I have 2 aspx page. on one page there exist only one button. on other page there exist one datagrid.
    when i press first page button i want Please wait screen appear when data is filled in datagrid on other page this Please wait screen disappear.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now