There are many ways to display a loading/custom message while a web page is processing. Mostly we like to display such message when there is some heavy processing happening during the page load. It is not preferred to show the user a blank screen while some processing happens at the server side.

 

Following are some of the ways we can achieve this:

 

1.     Using an Ajax call.

2.     Using javascript to submit the page and then perform the server side processing.

3.     Using Response.flush to flush the current data to the web page. (did not do much research o n this. but did not work in the page_load event. Worked when I used inline code.)

4.     Using the <Meta> tag to refresh the page.

 

 

Below is a quick sample showing a custom message on the web page while some processing happens at the server side. I have used the last method (Point 4) given in the list above to achieve this.

The reason I chose this approach because it looks like the easiest method with less code logic involved.

 

 

 

Step 1

 

HTML code for the web page:

 

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

 <Title>Copying Event</Title>

 <! ----- dynamically filled META REFRESH element ----->

 <Meta id="mtaRefresh" runat="server" />

</head>

<Body>

 <form id="frmMain" runat="server">

<! ----- "please wait" display ----->

<Center>

<p>&nbsp;</p><p>&nbsp;</p>

<div id="divWait" Visible="false" runat="server"><b>Processing, please wait...</b></div>

</Center>

</form>

 

</Body>

</html>

 

Step 2

 

Server side code on the Page_Load event if the web page would look something like this:

 

protected void Page_Load(object sender, EventArgs e)

{

    if (Request.QueryString["doAction"] == null)

    {

        string sRefreshURL = Request.Url.ToString();

        // use META REFRESH to start loading next page

        mtaRefresh.Attributes.Add("http-equiv", "refresh");

        mtaRefresh.Attributes.Add("content", "0;url=" + sRefreshURL + "&doAction=1");

 

        divWait.Visible = true;

    }

    else

    {

        <Server Side Code>

        divWait.Visible = true;

        divWait.InnerText = "Done";

    }

}