Vinz' Blog

"Code, Beer and Music" ~ my way of being a programmer!
posts - 124, comments - 366, trackbacks - 0

My Links

News

Archives

Image Galleries

Displaying Wait Message on Page Load in ASP.NET

This example simulates on how to display a loading message with gif image when the page loads in ASP.NET.


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

<head id="Head1" runat="server">

  <title>Load Wait Message Demo</title>

</head>

<script type="text/javascript" language="javascript">

  if(document.getElementById)
{ // IE 5 and up, FF

    var upLevel = true;

  }

else if(document.layers) { // Netscape 4

    var ns4 = true;

  }

  else
if(document.all) { //IE 4

     var ie4 = true;

  }

  function showObject(obj) {

  if(ns4) {

     obj.visibility = "show";

  }

  else if (ie4 || upLevel) {

     drawMessageBox();

obj.style.visibility = "visible";        

  }

}

     
showObject('splashScreen');

  function hideObject(obj) {

  if(ns4) {

        obj.visibility = "hide";

      }

      if(ie4 || upLevel) {

        obj.style.visibility = "hidden";

      }

}

  function drawMessageBox()

  {         
var box = "<div id='splashScreen'
style='position:absolute;z-index:5;top:30%;left:35%;'>"

            +"<table cellpadding='0' cellspacing='0' style='width:300px; height:200px;'>"

            +"<tr><td
style='width:100%; height:100%;font-family:Tahoma;' align='center'
valign='middle'>"

            +"<br/><br />"

            +"<IMG src='Images/Loading.gif' BORDER='0' Name='Progress'/>"

            +"   Please wait..."

            +"</td><td></td></tr>"

            +"</table>"

            +"</div>";

            document.write(box);

 }

</script>

<body>

<% Response.Flush();%>

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

        <% System.Threading.Thread.Sleep(3000);%>

    </form>

<% Response.Flush();%>

<script type="text/javascript" language="javascript">

  if(upLevel)
{

     var splash = document.getElementById("splashScreen");

  }

  else if(ns4) {

     var splash = document.splashScreen;

  }

  else if(ie4) {

     var splash = document.all.splashScreen;

  }

  hideObject(splash);

</script>

</body>

</html>







-->

Print | posted on Tuesday, February 17, 2009 5:18 PM |

Feedback

Gravatar

# re: Displaying Wait Message on Page Load in ASP.NET

I think your idea of using the dynamic or 'dirty' window technique
is the best solution possible. Thanks.
11/2/2009 4:44 AM | rpgivpgmr
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: