troubleshooting Question

ASP.net 2.0: Splash screen while grid view loads

Avatar of Robb Hill
Robb HillFlag for United States of America asked on
Web Development
33 Comments1 Solution1025 ViewsLast Modified:
I have a gridview that sometimes takes a while to load.  I want to make a slashscreen that displays while the user is waiting.

I am assuming I will have to do this in javascript...even though an asp.net 2.0 solution would be nicer.  Here is what I have so far in jscript.  Please help me modify this code...unless you have a nicer solution.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SplashScreen.aspx.vb" Inherits="_Default" %>

<!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>Untitled Page</title>
      <script type="text/javascript" language="javascript">

 

var preloadimages=new Array("sun.gif"," sun.gif")
var intervals=2000
var targetdestination="Gridrender.aspx"
var splashmessage=new Array()
var openingtags='<font face="Arial" size="4">'

splashmessage[0]='<img src="App_Themes/SandSky/Images/sun.gif"> Please Be Patient <img src="App_Themes/SandSky/Images/sun.gif">'
splashmessage[1]='Your Report Is Loading'
splashmessage[2]='Thank You'
splashmessage[3]='Please stand by...'

var closingtags='</font>'
var i=0
var ns4=document.layers?1:0
var ie4=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0
var theimages=new Array()

if (document.images){
    for (p=0;p<preloadimages.length;p++){
        theimages[p]=new Image()
        theimages[p].src=preloadimages[p]
        }
   }
 
function displaysplash(){
    if (i<splashmessage.length){
        sc_cross.style.visibility="hidden"
        sc_cross.innerHTML='<b><center>'+openingtags+splashmessage[i]+closingtags+'</center></b>'
        sc_cross.style.left=ns6?parseInt(window.pageXOffset)+parseInt(window.innerWidth)/2-parseInt(sc_cross.style.width)/2 : document.body.scrollLeft+document.body.clientWidth/2-parseInt(sc_cross.style.width)/2
        sc_cross.style.top=ns6?parseInt(window.pageYOffset)+parseInt(window.innerHeight)/2-sc_cross.offsetHeight/2 : document.body.scrollTop+document.body.clientHeight/2-sc_cross.offsetHeight/2
        sc_cross.style.visibility="visible"
        i++}
    else{
        window.location=targetdestination
        return}

    setTimeout("displaysplash()",intervals)
}

 

function displaysplash_ns(){
    if (i<splashmessage.length){
        sc_ns.visibility="hide"
        sc_ns.document.write('<b>'+openingtags+splashmessage[i]+closingtags+'</b>')
        sc_ns.document.close()
        sc_ns.left=pageXOffset+window.innerWidth/2-sc_ns.document.width/2
        sc_ns.top=pageYOffset+window.innerHeight/2-sc_ns.document.height/2
        sc_ns.visibility="show"
        i++}
    else{
    window.location=targetdestination
    return
    }
    setTimeout("displaysplash_ns()",intervals)
    }

 

function positionsplashcontainer(){
    if (ie4||ns6){
        sc_cross=ns6?document.getElementById("splashcontainer"):document.all.splashcontainer
        displaysplash()
    }
    else if (ns4){
        sc_ns=document.splashcontainerns
        sc_ns.visibility="show"
        displaysplash_ns()
    }
    else
        window.location=targetdestination
    }
    window.onload=positionsplashcontainer
 
 
  </script>
   
</head>
<body>
    <form id="form1" runat="server">
   
    <div id="splashcontainer" style="position:absolute;width:350px;"></div>
    <layer id="splashcontainerns" width="450"></layer>
    </form>
</body>
</html>
ASKER CERTIFIED SOLUTION
bigphuckinglizard

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 33 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 33 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros