Transition Page

R

Roger Cantillo

Anyone know what I can do to build a transition page while ASP code runs in
the background? Looking for something to say "Please wait while
loading....."
 
S

Shailesh Humbad

Make sure to put Response.write Space(256) before the Response.flush.
IE has a behaviour (bug?) where it won't display any part of the page
until at least 256 bytes have been sent. Here are three functions you
can use.


' Wait page functions
Sub PrintWaitPageHeader(strHeaderMessage)
Response.write "<html><body>"&vbCrLf
Response.write "<h2>"&strHeaderMessage&"</h2>"&Space(256)&vbCrLf
Response.Flush
End Sub

Sub PrintWaitPageStatus(strStatusMessage)
Response.write strStatusMessage&Space(256)&vbCrLf
Response.Flush
End Sub

Sub PrintWaitPageComplete(strRedirectURL)
Response.write "<script type="&Chr(34)&"text/javascript"&Chr(34)&">"&vbCrLf
Response.write "document.location.href='"&strRedirectURL&"';"&vbCrLf
Response.write "</script>"&vbCrLf
Response.write "<p>"&Space(256)&vbCrLf
Response.write "<p>If the page does not transfer, <a href="&_
Chr(34)&strRedirectURL&Chr(34)&">click here.</a>"&vbCrLf
Response.write "</body></html>"
Response.Flush
End Sub

Shailesh
 
R

Roger Cantillo

Will Response.Flush give any trouble when accessing form data via
Request.Form?
 
R

Ray at

Ah, that's what's testing is for...

<form method="post" action="test.asp">
<input name="x">
<input type="submit">
</form>

<%
response.write request.form("x") & "<hr>"
response.flush
response.write "Request was flushed. Can I still get x?<br>"
response.write request.form("x")
response.end
%>

Ray at work
 
R

Roger Cantillo

I tried response.flush and it works great. The reason I ask is because I'm
submitting a lot of data via the POST method, and I don't want to lose any
of it. Just being overly cautious.
 
J

Jon Mundsack

Shailesh Humbad said:
Make sure to put Response.write Space(256) before the Response.flush.
IE has a behaviour (bug?) where it won't display any part of the page
until at least 256 bytes have been sent. Here are three functions you
can use.

Great tip. No wonder I could never make this work before!

-Jon
 
L

Larry Woods

I asked the same original question a few minutes ago and was referred to
this thread...and it is 90% of what I want. The only problem that I have is
that I want to get rid of the "Please wait message" after the page has
filled. Am I looking at some sort of redirect???

TIA,

Larry Woods
 
S

Shailesh Humbad

Flushing the Response object should have no effect on any part of the
Request object.

I had the transition pages working in Mozilla, but they failed in IE.
So a lot of Google hunting later, I found the tip. I'm glad you like it
too! :)

S.
 
S

Shailesh Humbad

Put the message in a div or span tag and give it a unique id, like:
<div id="waitmessage">Please wait...</div>

In the Javascript, replace the line that does the redirect
(location.href=...) with a call to the show/hide functions from here:

http://getelementbyid.com/scripts/index.aspx?CodeID=5

If you want the message to collapse out of the page as well as
disappear, then add a line like:

document.getElementById(id).style.position = "absolute";

to collapse, and if you want to show again, like:

document.getElementById(id).style.position = "relative";

This should work like a charm in most browsers nowadays. There are a
lot of other ways to hide the "please wait" message once the page loads,
but these are more appropriate for a Javascript/HTML forum.

Shailesh
 
L

Larry Woods

Thanks, Ray.

Tried the code but can't get it to work with NS so won't work... Public
site.

Larry
 
C

Chris Barber

As an interesting addition, you can write intermittent script sections to
the page as the document loads and modify the .value and .display of a
button to display some text (eg. 10%, 20%, 30% etc).

eg.

<%
'Percentage is anything from 0 to 100
Sub WriteProgress(pstrProgress)
Response.Write "<script>"
Response.Write " var pobjButton =
document.getElementById('progressbutton')";
Response.Write " pobjButton.value = '" & pstrProgress & "';"
Response.Write "</script>"
'Make sure this gets sent.
Response.Flush
End Sub

Sub ClearProgress()
Response.Write "<script>"
Response.Write " var pobjButton =
document.getElementById('progressbutton')";
Response.Write " pobjButton.style.display = 'none';"
Response.Write "</script>"
'Make sure this gets sent.
Response.Flush
End Sub
%>

<!-- Add the relevant style properties to change the button to look like
normal text ? -->
<input id="progressbutton" type="button" style="border: 1px solid black;
width: 120px" value="Loading: 0%"/>

<%
'Do some work and repeatedly (eg. a loop):
For i = 1 to 100
WriteProgress "Progress: " & i & "%"
Next
WriteProgress "Progress: Done"
ClearProgress

%>

Of course you can optimise the JavaScript a bit more by using functions
defined at the top of the page etc.

Chris.

Thanks, Ray.

Tried the code but can't get it to work with NS so won't work... Public
site.

Larry
 
B

Brian Staff

Beware - issuing a response.flush in the middle of <table> structure does
not cause that data to display. The render cannot take place until the
complete table has been sent. Many web pages are a combination of nested
tables, so your technique may not work as you described.

Brian Staff
 
C

Chris Hohmann

Larry Woods said:
Thanks, Ray.

Tried the code but can't get it to work with NS so won't work... Public
site.

Larry

Peter-Paul Koch has written a definitive article on "object detection"
as a methodology for cross-browser support.
http://www.xs4all.nl/~ppk/js/support.html

He also has a DHTML example page that implements object detection to
make text invisible. Cutting and pasting is left as an exercise for the
reader. ;-)
http://www.xs4all.nl/~ppk/js/cross_dhtml.html

HTH
-Chris
 
C

Chris Barber

OK - for full tables that may be the case (and probably is). I usually work
around that by constructing mini-tables.

I was more aiming this at longish running server-side ASP stuff (eg. 20-30
seconds) where you may want to keep the user informed of the progress and
then move to another page at the end of it.

It's not a proposed solution to the ops post but a side-interest that may
help - the first couple of responses to the ops post were suggesting a
repeated response.write that would result in a new line of text being
appended to the page each time. The scenario that I outline would allow
(with a bit of work) a pseudo-progress bar (moving etc.) to be implemented
(in fact I've done it a few times in just that way).

Cheers,

Chris.

Beware - issuing a response.flush in the middle of <table> structure does
not cause that data to display. The render cannot take place until the
complete table has been sent. Many web pages are a combination of nested
tables, so your technique may not work as you described.

Brian Staff
 
S

Shailesh Humbad

It happened on Windows 2000 Server with I believe IE 5.0 or 5.5 (IIS and
IE running on same machine). It doesn't seem to happen on my Windows XP
Pro/IE 6.0 machine.

Shailesh
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,218
Latest member
JolieDenha

Latest Threads

Top