Geeks With Blogs

News

Microsoft MVP


DZone MVB


Moderator at CodeASP.NET


Quiz Master







free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"
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>






</html->
Technorati Tags: ,
--> Posted on Tuesday, February 17, 2009 5:18 PM ASP.NET , JavaScript | Back to top


Comments on this post: Displaying Wait Message on Page Load in ASP.NET

# re: Displaying Wait Message on Page Load in ASP.NET
Requesting Gravatar...
I think your idea of using the dynamic or 'dirty' window technique
is the best solution possible. Thanks.
Left by rpgivpgmr on Nov 02, 2009 4:44 AM

# re: Displaying Wait Message on Page Load in ASP.NET
Requesting Gravatar...
Thanks for this solution. I did have a little problem with it using IE8 (did not test other browsers. Seems that the drawMessageBox() function needed to be called before the Object was passed to the showObject() function. I changed the showObject() as follows:
function showObject() {
drawMessageBox();
var obj = document.getElementById("splashScreen");
if (ns4) {
obj.visibility = "show";
}
else if (ie4 || upLevel) {
obj.style.visibility = "visible";
}
}
showObject();

I don't know a lot about javascript language so I hope Ihave not created other problems; (I don't know if getElementById() works for Netscape 4) but, this seems to work ok for me.

I also moved the styling of the box to an external css and tweaked the <table> a little for my own style.

Thanks a million for the solution. I would never have known how to do this myself.
Left by RichardY on Oct 18, 2010 3:28 AM

# re: Displaying Wait Message on Page Load in ASP.NET
Requesting Gravatar...
very good article ,for me its working perfectly
Left by varaprasad on Dec 21, 2010 11:59 PM

# re: Displaying Wait Message on Page Load in ASP.NET
Requesting Gravatar...
Hi I am using your script but while i am running in IE7 i am getting this error
Microsoft JScript runtime error: 'upLevel' is undefined

Please reply me soon
Left by Vigneshwar on Apr 26, 2011 5:25 PM

# re: Displaying Wait Message on Page Load in ASP.NET
Requesting Gravatar...
I am getting style is null or not an object error
Left by simon on Jan 13, 2012 12:41 PM

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net