Showing "Template" + feedback for a page that takes a long time toprocess.

B

Brent

Like many sites, mine has a standard "look" -- a template, if you will
-- that visitors see on each page. I've tried to keep the code and HTML
separate to the extent possible, and for most standard page
presentations, it works well.

However, I have a couple of screen scrape / import routines that can
take minutes, even hours, to complete. I'd like to have some way of
outputting my template first to the browser, and then within the
template, providing feedback to the user as the import progresses. I've
yet to figure out how to do this. If I do, e.g. ... (pseudo code)

<script runat="server">

Response.Write(userfeedback);
Response.Flush;
</script>

....from within the code, I can provide good feedback, but these lines
will end up in the browser before any the rest of the template arrives.

If, instead I do, e.g. ... (pseudo code)

<script runat="server">
StringBuilder sb = new Stringbuilder();
sb.Append(userfeedback);
myControl.Text = sb.ToString();
</script>
<html>
<body>

<asp:Literal id="myControl" runat="server" />
</body>
</html>

....I may have to wait a very long time before seeing anything on the screen.

Is there any way to output the template first, and then target my
Response.Write/Response.Flush statements to, say, a <div> or some kind
of <asp:n> control?

Thanks for any input!

--Brent
 
B

Bruce Barker

this is probably a bad approach. minutes is sorta ok, hours is too long, the
browser will shut down. also if the user get bored, and quicks, your
execution will abort. you shoudl swich to a queueing syatem where the page
queues up the request, then polls for the results. this means if it runs for
1/2 hour, the user can go away, come back and check the status.

your current approach is push content to the browser and have it rendered
right away. this will work as long as the markup is simple. if you
processing message appear in a table, then the browser will wait for the end
tags of the table before rendering, and thus defeat you purpose. if you want
header to apper try this:

<html>
<!-- all my template stuff -->
<script runat=server>
DoLongRunngProcess();
</script>
<!-- more template stuff>
</html>

in DoLongRunngProcess(), call Response.Write(), Response.Flush() to output
your processing messages. be sure page Buffering is turned off. remeber if
the template is too complex the browser may not render until all html has
been received.


-- bruce (sqlwork.com)
 
B

Brent

Thanks, Bruce.

Do you have a place I can learn about queuing and polling? Sounds like a
better option!

--Brent
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top