Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can ASP ever be "real-time" ?

Status
Not open for further replies.

Iliemoo

Programmer
Sep 25, 2002
64
0
0
CA
Hi all, can classic ASP pages every give real time display? One user came to me with a complaint about a web page that loads data from a database does not display loading progress in a sequential fashion anymore. The page basically loads data from various tables, and he claims that when while each table loads there will be trailing periods growing on the page.

From my understanding of ASP that is impossible :( since the code is process on the server and will return a page only when “everything” is done. But he seems so sure that he saw the page change in real time … should I give him the benefit of the doubt? (There’s no javascript of any kind on the page)
 
You can use period response.flush statements to show the page as its being completed.

I have a page that takes hours to run but the repsonse.flush lets me know the current status of the report run...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
set the buffer to true and the page should load as the content is outputted.

you can see this effect at

the iFrames should (if not to quick) load portions of the content DB driven as it is outputted

____________________________________________________
[sub][/sub]
onpnt2.gif

 
oops = "period" ---> "periodic"

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
must have been the old click concurrently between us again mwolf. didn't see your post

glad to see you have free time again. [smile]

____________________________________________________
[sub][/sub]
onpnt2.gif

 
>> set the buffer to true and the page should load as the
>> content is outputted.

Code:
<html><body><table>
.... put all output html in this table
</table></body></html>[code]

Most browsers will not render the table until the close tag is received. There are some exceptions but generally don't use a table that way if you want to achieve the effect being discussed here.


-pete
 
As far as loading messages go, take a look at the FAQs, someone *cough* wrote up a FAQ about in page wait messages.

What you could do to get the incrementing periods effect is expand the example in there to spit out periods every once in a while after major blocks of ASP code. Or you could spit out a piece of javascript to update the message with a new message, for instance change it from 10% to 20%.

I'll dig around and see if I still have my loading bar anywhere...

Onpnt: didn't you have a realtime loading bar at some point? (if your using this already on your site and thats what you were pointing to, ignore this statement :) )

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
*cough* yeah I did but I did a booboo while transfering everything to the new server.

*cough*
*cough*
*cough*

I have to tell you all. *cough* The FAQ *cough* wrote, is a *cough*good*cough* one as even I use it at teh link shown above. With a *cough* slight mod to it you can have any effect occur as the loading bar etc..


1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
<offtopic>
*bows* I do try (sig line)...or did rather, to much on my plate right now...thankfully I was able to put off the moving date until Feb...still only have 4 months till my engagement deadline though...women ;)
</offtopic>

I did have a javascript loading bar, so I fiddled with it and created a version that could be triggered from ASP...it also has a neat sliding number feature that was quite accidental...
Code:
<%
Option Explicit

'-------------------- Functions -----------------------------------
Sub OutputTimerHead
	%>
	<style>
	.redline{
		height:10px;
		width:0px;
		background-color:red;
	}
	.greenline{
		height:10px;
		width:200px;
		background-color:green;
	}
	</style>
	<script>
	var rl,maxSize;
	function running(message){
		nSize = maxSize/100 * 200;//convert to the 200 pixel width

		rl.style.pixelWidth = rl.style.pixelWidth + 1;
		if(rl.style.pixelWidth<=nSize) 
			setTimeout(&quot;running('&quot; + message + &quot;');&quot;,10);
		else
			rl.innerHTML = &quot;<center>&quot; + message + &quot;</center>&quot;;
	}
	</script>
	<%
End Sub

Sub OutputBars
	%>
	<div style=&quot;height:10px;width:200px;&quot; class=&quot;greenline&quot; id=&quot;greenline&quot;><div id=&quot;redline&quot; class=&quot;redline&quot; style=&quot;height:10px;width:10px;&quot;>&nbsp;</div></div>
	<script language=&quot;Javascript&quot;>
		rl = document.getElementById(&quot;redline&quot;)
	</script>
	<%
	Response.Flush
End Sub

Sub IncreaseLoadBar(amt)
	%>
	<script language=&quot;Javascript&quot;>
	maxSize = <%=amt%>;
	running(&quot;<%=amt%>%&quot;);
	</script>
	<%
	Response.Flush
End Sub

Sub DisappearTheBar
	%>
	<script language=&quot;Javascript&quot;>
		document.getElementById(&quot;greenline&quot;).style.display=&quot;none&quot;;
	</script>
	<%
End Sub

'--------------------- Sample ---------------------------------

Response.Write &quot;<html><head>&quot;
OutputTimerHead
Response.Write &quot;</head><body>&quot;
Response.Write &quot;Here we go!<br>&quot;
OutputBars

'load the load bar to 5%
IncreaseLoadBar 5

'-- fake delay from workload
Dim tm, ttm
ttm = Now
tm = dateAdd(&quot;s&quot;,4,Now)
Response.Write &quot;Time now: &quot; & ttm & &quot; calculating junk until &quot; & tm & &quot;<br>&quot;
Do Until ttm > tm
	ttm = Now
Loop
'-- end fake delay

'load the load bar to 25%
IncreaseLoadBar 25

'--- more fake delay
ttm = Now
tm = dateAdd(&quot;s&quot;,4,Now)
Response.Write &quot;Time now: &quot; & ttm & &quot; calculating junk until &quot; & tm & &quot;<br>&quot;
Do Until ttm > tm
	ttm = Now
Loop

'load the load bar to 50%
IncreaseLoadBar 50

'--- more fake delay
ttm = Now
tm = dateAdd(&quot;s&quot;,4,Now)
Response.Write &quot;Time now: &quot; & ttm & &quot; calculating junk until &quot; & tm & &quot;<br>&quot;
Do Until ttm > tm
	ttm = Now
Loop

'load the load bar to 75%
IncreaseLoadBar 75

'--- more fake delay
ttm = Now
tm = dateAdd(&quot;s&quot;,4,Now)
Response.Write &quot;Time now: &quot; & ttm & &quot; calculating junk until &quot; & tm & &quot;<br>&quot;
Do Until ttm > tm
	ttm = Now
Loop

'load the load bar to 100%
IncreaseLoadBar 100

'get rid of the darn bar :)
DisappearTheBar
%>

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top