Display animation while waiting for server to respond.

J

jensen bredal

Hello,

I attended a seminar with scott gu. Microsoft asp.net lead guru, and he
mentioned some advanced
javascript that let you display an animation while your page is waiting for
response from the server.

He said these scripts could be found on his blog but , so far i have not
been able to find them.
I did send him an e-mail but no luck, no response.

Does anyone know of these script or know how to do this?

Many thanks in advance

JB
 
W

Web Team @ Borough of Poole

Try this:

<html>
<head>
<title></title>
<script language="javascript">
function toggle(e) {
if (e.style.display == "none") {
e.style.display = "";
} else {
e.style.display = "none";
}
}
</script>
</head>
<body onload="toggle(progress)">
<div id="progress">Animation/Text/What Ever Here</div>
</body>
</html>

Hope that helps.

Simon.
 
J

jensen bredal

}
}
</script>
</head>
<body onload="toggle(progress)">
<div id="progress">Animation/Text/What Ever Here</div>
</body>
</html>

Hope that helps.

Simon.

Great,
Thank you
JB
 
J

jensen bredal

</head>
<body onload="toggle(progress)">
<div id="progress">Animation/Text/What Ever Here</div>
</body>
</html>

Hope that helps.

Simon.

How should this be used in an aspx page?

In your example, shouldn't it display "Animation/Text/What Ever Here" until
the page i rendered?

This is not what happens in my case. I still see white background while page
is loading.
 
B

billmiami2

JB,

Instead of having the user call the slow-loading page directly, you
will need to create an intermediate page. You pass the URL (with
querystring) of the slow-loading page to the intermediate page, which
in turn calls the slow-loading page using javascript. In the interim,
it does something (shows "progress bar", message or animation).

I have attached some example script which should help you. The initial
calling page is called orderstart.aspx. The intermediate page is
pageload.aspx and the slow-loading page is called ordercomplete.aspx
(not shown here directly). This code is from an asp.net "Black belt"
presentation by INETA.

Bill E.
Hollywood, FL
________________________________
orderstart.aspx.vb

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Server.Transfer("PageLoad.aspx?Page=ordercomplete.aspx?partnumber=" &
TextBox1.Text, True)
End Sub
________________________________
pageload.aspx

<HTML>
<HEAD>
<title>PageLoad</title>
<script language="javascript">

var iLoopCounter = 1;
var iMaxLoop = 6;
var iIntervalId;

function BeginPageLoad() {
location.href = "<%= Request.QueryString("Page")%>";
iIntervalId =
window.setInterval("iLoopCounter=UpdateProgressMeter(iLoopCounter,
iMaxLoop)", 500);
}

function EndPageLoad() {
window.clearInterval(iIntervalId);
ProgressMeter.innerText = "Page Loaded -- Not Transferring";
}

function UpdateProgressMeter(iCurrentLoopCounter, iMaximumLoops) {

iCurrentLoopCounter += 1;

if (iCurrentLoopCounter <= iMaximumLoops) {
ProgressMeter.innerText += ".";
return iCurrentLoopCounter;
}
else {
ProgressMeter.innerText = "";
return 1;
}
}

</script>
</HEAD>
<body onload="BeginPageLoad()" onunload="EndPageLoad()">
<form id="Form1" method="post" runat="server">
<table border="0" cellpadding="0" cellspacing="0" width="99%"
height="99%" align="center"
valign="middle">
<tr>
<td align="center" valign="middle">
<font color="navy" size="7">
<span id="MessageText">Processing Order&nbsp;-- Please
Wait</span>
<span id="ProgressMeter"
style="WIDTH:25px;TEXT-ALIGN:left"></span>
</font>
</td>
</tr>
</table>
</form>
</body>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top