Console-ish output in a browser, how?

Console-ish output in a browser, how?

am 20.12.2007 16:21:34 von gnewsgroup

In my web application, I would like to dynamically display the
progress of a process, something like:

Collecting user input ...
Saving user profile ...
Generating report in PDF ...
Dispatching report to user email ...

This is something like the installation progress display of DotNetNuke
or the Oracle's web-based enterprise manager.

Any idea about how this is implemented? I sorta think it is a iframe,
but just a wild guess.

Thanks.

RE: Console-ish output in a browser, how?

am 20.12.2007 17:45:02 von brucebarker

its done with server push. turn off page bufferring

DoSomeWork();
Response.Write("working 1...
");
Rsponse.Flush();
DoSomeWork();
Response.Write("working 2...
");
Rsponse.Flush();

the markup must be simple or the browser will not render it until all of it
is recieved.

-- bruce (sqlwork.com)


"gnewsgroup" wrote:

> In my web application, I would like to dynamically display the
> progress of a process, something like:
>
> Collecting user input ...
> Saving user profile ...
> Generating report in PDF ...
> Dispatching report to user email ...
>
> This is something like the installation progress display of DotNetNuke
> or the Oracle's web-based enterprise manager.
>
> Any idea about how this is implemented? I sorta think it is a iframe,
> but just a wild guess.
>
> Thanks.
>

Re: Console-ish output in a browser, how?

am 20.12.2007 17:51:42 von dlongnecker

My recommendation would be to use a ListBox control and insert items into
it as you return out messages to the user.

Using .Insert() at the zero index ensures that the newest messages show up
at the top...

Here's an example:

On your ASPX page:





In your code-behind, classes, etc:

// Put an "item" for each line in the "console" output.
ConsoleOutput.Items.Insert(0, "Collecting user input ...");
ConsoleOutput.Items.Insert(0, "Saving user profile ...");
ConsoleOutput.Items.Insert(0, "Generating report in PDF ...");
ConsoleOutput.Items.Insert(0, "Dispatching report to user email
....");

ConsoleOutput.Items.Insert(0, "Collecting user input again... ");
ConsoleOutput.Items.Insert(0, "Saving another user profile ...");
ConsoleOutput.Items.Insert(0, "Generating another report in PDF
....");
ConsoleOutput.Items.Insert(0, "Dispatching the final report to
user email ...");

Events could fire off the control updating and/or placing it in an UpdatePanel
so your users can see it "scroll"...

HTH!

-dl

--
David R. Longnecker
http://blog.tiredstudent.com

> In my web application, I would like to dynamically display the
> progress of a process, something like:
>
> Collecting user input ...
> Saving user profile ...
> Generating report in PDF ...
> Dispatching report to user email ...
> This is something like the installation progress display of DotNetNuke
> or the Oracle's web-based enterprise manager.
>
> Any idea about how this is implemented? I sorta think it is a iframe,
> but just a wild guess.
>
> Thanks.
>

Re: Console-ish output in a browser, how?

am 20.12.2007 18:02:47 von gnewsgroup

On Dec 20, 11:45 am, bruce barker
wrote:
> its done with server push. turn off page bufferring
>
> DoSomeWork();
> Response.Write("working 1...
");
> Rsponse.Flush();
> DoSomeWork();
> Response.Write("working 2...
");
> Rsponse.Flush();
>
>

I had thought that it must be something trickier than this. Will
Thread.Sleep(2000) work in a webpage? In other words, will the next
output appear after 2 seconds' elapse like so?

DoSomeWork();

Thread.Sleep(2000);

Response.Write("working 1...
");
Rsponse.Flush();
DoSomeWork();

Thread.Sleep(2000);

Response.Write("working 2...
");
Rsponse.Flush();

I tried Thread.Sleep before in a webpage, it does not seem to work.

Re: Console-ish output in a browser, how?

am 20.12.2007 18:05:53 von gnewsgroup

On Dec 20, 11:51 am, David R. Longnecker
wrote:
> My recommendation would be to use a ListBox control and insert items into
> it as you return out messages to the user.
>
> Using .Insert() at the zero index ensures that the newest messages show up
> at the top...
>
> Here's an example:
>
> On your ASPX page:
>
>


>
>

>
> In your code-behind, classes, etc:
>
> // Put an "item" for each line in the "console" output.
> ConsoleOutput.Items.Insert(0, "Collecting user input ...");
> ConsoleOutput.Items.Insert(0, "Saving user profile ...");
> ConsoleOutput.Items.Insert(0, "Generating report in PDF ...");
> ConsoleOutput.Items.Insert(0, "Dispatching report to user email
> ...");
>
> ConsoleOutput.Items.Insert(0, "Collecting user input again... ");
> ConsoleOutput.Items.Insert(0, "Saving another user profile ...");
> ConsoleOutput.Items.Insert(0, "Generating another report in PDF
> ...");
> ConsoleOutput.Items.Insert(0, "Dispatching the final report to
> user email ...");
>
> Events could fire off the control updating and/or placing it in an UpdatePanel
> so your users can see it "scroll"...
>
> HTH!
>
> -dl
>

Thanks, I think your idea is absolutely cool. But, I guess it is then
necessary to CSS-format your listbox and make the frame and scroll bar
invisible. What do you think?

Re: Console-ish output in a browser, how?

am 20.12.2007 20:14:07 von dlongnecker

That's a good question--I've never had a great deal of luck styling ListBox
controls. If I need really heavy duty theming, I tend to create composite
controls of my own.

If you wanted the box to expand dynamically (rather than scroll), that's
possible too.. You could refactoring out the .Insert command and do something
like:

protected void Page_Load(object sender, EventArgs e)
{
// Put an "item" for each line in the "console" output.
ConsoleWriter(ConsoleOutput, "Collecting user input ...");
ConsoleWriter(ConsoleOutput, "Saving user profile ...");
ConsoleWriter(ConsoleOutput, "Generating report in PDF ...");
ConsoleWriter(ConsoleOutput, "Dispatching report to user email
....");

ConsoleWriter(ConsoleOutput, "Collecting user input again... ");
ConsoleWriter(ConsoleOutput, "Saving another user profile ...");
ConsoleWriter(ConsoleOutput, "Generating another report in PDF
....");
ConsoleWriter(ConsoleOutput, "Dispatching the final report to
user email ...");
}

protected void ConsoleWriter(ListBox listBox, string textToWrite)
{
listBox.Items.Insert(0, textToWrite);
listBox.Rows = listBox.Items.Count + 1;

}

That'll keep the ListBox 1 line "bigger" (that may not even be necessary,
can try with and without the +1) than the data it's holding. I'm sure others
on here have some creative ideas as well--I've just never sat down and hacked
out the actual ListBox control. :)

Good luck!

-dl

--
David R. Longnecker
http://blog.tiredstudent.com

> On Dec 20, 11:51 am, David R. Longnecker
> wrote:
>> My recommendation would be to use a ListBox control and insert items
>> into it as you return out messages to the user.
>>
>> Using .Insert() at the zero index ensures that the newest messages
>> show up at the top...
>>
>> Here's an example:
>>
>> On your ASPX page:
>>
>>


>>
>>

>> In your code-behind, classes, etc:
>>
>> // Put an "item" for each line in the "console" output.
>> ConsoleOutput.Items.Insert(0, "Collecting user input ...");
>> ConsoleOutput.Items.Insert(0, "Saving user profile ...");
>> ConsoleOutput.Items.Insert(0, "Generating report in PDF ...");
>> ConsoleOutput.Items.Insert(0, "Dispatching report to user email
>> ...");
>>
>> ConsoleOutput.Items.Insert(0, "Collecting user input again... ");
>> ConsoleOutput.Items.Insert(0, "Saving another user profile ...");
>> ConsoleOutput.Items.Insert(0, "Generating another report in PDF
>> ...");
>> ConsoleOutput.Items.Insert(0, "Dispatching the final report to
>> user email ...");
>> Events could fire off the control updating and/or placing it in an
>> UpdatePanel so your users can see it "scroll"...
>>
>> HTH!
>>
>> -dl
>>
> Thanks, I think your idea is absolutely cool. But, I guess it is then
> necessary to CSS-format your listbox and make the frame and scroll bar
> invisible. What do you think?
>

Re: Console-ish output in a browser, how?

am 20.12.2007 20:28:01 von MohamadElarabi

You can also set Response.Buffer = False at the top of your page and you
won't have to do all the Response.Flush() commands. Essentially you're
turning off bufferring so all responses are immediately sent to the browser.

tip: This also helps when a part of the page is taking a long time to load
while the rest of the page is fast. Instead of holding everybody hostage
you'd turn off the buffer and the slow image etc would load on its own sweet
time.

--
Mohamad Elarabi
Lead Developer. MCTS, MCPD.


"gnewsgroup" wrote:

> On Dec 20, 11:45 am, bruce barker
> wrote:
> > its done with server push. turn off page bufferring
> >
> > DoSomeWork();
> > Response.Write("working 1...
");
> > Rsponse.Flush();
> > DoSomeWork();
> > Response.Write("working 2...
");
> > Rsponse.Flush();
> >
> >
>
> I had thought that it must be something trickier than this. Will
> Thread.Sleep(2000) work in a webpage? In other words, will the next
> output appear after 2 seconds' elapse like so?
>
> DoSomeWork();
>
> Thread.Sleep(2000);
>
> Response.Write("working 1...
");
> Rsponse.Flush();
> DoSomeWork();
>
> Thread.Sleep(2000);
>
> Response.Write("working 2...
");
> Rsponse.Flush();
>
> I tried Thread.Sleep before in a webpage, it does not seem to work.
>

Re: Console-ish output in a browser, how?

am 21.12.2007 01:45:44 von zhaojk

On Dec 20, 2:14 pm, David R. Longnecker
wrote:
> That's a good question--I've never had a great deal of luck styling ListBox
> controls. If I need really heavy duty theming, I tend to create composite
> controls of my own.
>
> If you wanted the box to expand dynamically (rather than scroll), that's
> possible too.. You could refactoring out the .Insert command and do something
> like:
>
> protected void Page_Load(object sender, EventArgs e)
> {
> // Put an "item" for each line in the "console" output.
> ConsoleWriter(ConsoleOutput, "Collecting user input ...");
> ConsoleWriter(ConsoleOutput, "Saving user profile ...");
> ConsoleWriter(ConsoleOutput, "Generating report in PDF ...");
> ConsoleWriter(ConsoleOutput, "Dispatching report to user email
> ...");
>
> ConsoleWriter(ConsoleOutput, "Collecting user input again... ");
> ConsoleWriter(ConsoleOutput, "Saving another user profile ...");
> ConsoleWriter(ConsoleOutput, "Generating another report in PDF
> ...");
> ConsoleWriter(ConsoleOutput, "Dispatching the final report to
> user email ...");
> }
>
> protected void ConsoleWriter(ListBox listBox, string textToWrite)
> {
> listBox.Items.Insert(0, textToWrite);
> listBox.Rows = listBox.Items.Count + 1;
>
> }
>
> That'll keep the ListBox 1 line "bigger" (that may not even be necessary,
> can try with and without the +1) than the data it's holding. I'm sure others
> on here have some creative ideas as well--I've just never sat down and hacked
> out the actual ListBox control. :)
>
> Good luck!
>
> -dl

Thank you very much. It's nice, but I still would rather not to see
the frame of the listbox. I believe this can be done through css
formating. I've seen people do similar stuffs with TextBox.

Re: Console-ish output in a browser, how?

am 21.12.2007 18:03:01 von brucebarker

with the minor issuse that it will not appear until all processing is done
(page renders).

while you could use an ajax update panel, you would need to make a
request/postback per step.

a common server push approach is to post to an iframe, then render script to
update the main frame (google does this).

-- bruce (sqlwork.com)


"David R. Longnecker" wrote:

> My recommendation would be to use a ListBox control and insert items into
> it as you return out messages to the user.
>
> Using .Insert() at the zero index ensures that the newest messages show up
> at the top...
>
> Here's an example:
>
> On your ASPX page:
>
>


>
>

>
> In your code-behind, classes, etc:
>
> // Put an "item" for each line in the "console" output.
> ConsoleOutput.Items.Insert(0, "Collecting user input ...");
> ConsoleOutput.Items.Insert(0, "Saving user profile ...");
> ConsoleOutput.Items.Insert(0, "Generating report in PDF ...");
> ConsoleOutput.Items.Insert(0, "Dispatching report to user email
> ....");
>
> ConsoleOutput.Items.Insert(0, "Collecting user input again... ");
> ConsoleOutput.Items.Insert(0, "Saving another user profile ...");
> ConsoleOutput.Items.Insert(0, "Generating another report in PDF
> ....");
> ConsoleOutput.Items.Insert(0, "Dispatching the final report to
> user email ...");
>
> Events could fire off the control updating and/or placing it in an UpdatePanel
> so your users can see it "scroll"...
>
> HTH!
>
> -dl
>
> --
> David R. Longnecker
> http://blog.tiredstudent.com
>
> > In my web application, I would like to dynamically display the
> > progress of a process, something like:
> >
> > Collecting user input ...
> > Saving user profile ...
> > Generating report in PDF ...
> > Dispatching report to user email ...
> > This is something like the installation progress display of DotNetNuke
> > or the Oracle's web-based enterprise manager.
> >
> > Any idea about how this is implemented? I sorta think it is a iframe,
> > but just a wild guess.
> >
> > Thanks.
> >
>
>
>
>

Re: Console-ish output in a browser, how?

am 21.12.2007 20:03:02 von gnewsgroup

On Dec 21, 12:03 pm, bruce barker
wrote:
> with the minor issuse that it will not appear until all processing is done
> (page renders).
>
> while you could use an ajax update panel, you would need to make a
> request/postback per step.
>
> a common server push approach is to post to an iframe, then render script to
> update the main frame (google does this).
>
> -- bruce (sqlwork.com)

I just tried your approach, like what you've said, it will not appear
until all processing is done. In other words, you don't see those
output one after another with some pause in between them, even if you
use Thread.Sleep(5000) after each output. It does not work. You see
them all at once when the page renders.

Not sure how DotNetNuke does it for their installation process.

Re: Console-ish output in a browser, how?

am 21.12.2007 20:57:01 von MohamadElarabiMCPD

You must set Response.Buffer = False for response to go to the client
immediately. Please read my previous post.

Thanks,
--
Mohamad Elarabi
MCP, MCTS, MCPD.


"gnewsgroup" wrote:

> On Dec 21, 12:03 pm, bruce barker
> wrote:
> > with the minor issuse that it will not appear until all processing is done
> > (page renders).
> >
> > while you could use an ajax update panel, you would need to make a
> > request/postback per step.
> >
> > a common server push approach is to post to an iframe, then render script to
> > update the main frame (google does this).
> >
> > -- bruce (sqlwork.com)
>
> I just tried your approach, like what you've said, it will not appear
> until all processing is done. In other words, you don't see those
> output one after another with some pause in between them, even if you
> use Thread.Sleep(5000) after each output. It does not work. You see
> them all at once when the page renders.
>
> Not sure how DotNetNuke does it for their installation process.
>

Re: Console-ish output in a browser, how?

am 21.12.2007 22:18:28 von gnewsgroup

On Dec 21, 2:57 pm, Mohamad Elarabi [MCPD]
wrote:
> You must set Response.Buffer = False for response to go to the client
> immediately. Please read my previous post.
>
> Thanks,
> --
> Mohamad Elarabi
> MCP, MCTS, MCPD.
>

Yes, Mohamad, thank you. I did set Response.Buffer= false; But it
does not work as expected.

Re: Console-ish output in a browser, how?

am 22.12.2007 00:10:01 von MohamadElarabiMCPD

This code works on my box:

<%@ Page Language="VB" Theme="" AutoEventWireup="false" title="Untitled
Page" %>

<%
Response.Buffer = False

System.Threading.Thread.Sleep(2000)
Response.Write(Now & "
")
System.Threading.Thread.Sleep(2000)
Response.Write(Now & "
")
System.Threading.Thread.Sleep(2000)
Response.Write(Now & "
")
%>

And this is the output:

12/21/2007 3:03:34 PM
12/21/2007 3:03:36 PM
12/21/2007 3:03:38 PM


And this is how it looks in the browser:

12/21/2007 3:03:34 PM
12/21/2007 3:03:36 PM
12/21/2007 3:03:38 PM

It did write it out 2 seconds at a time.
Are you doing this in one of the page events? Maybe you have to do it inline
to work. Let me know if this works for you.

Thanks,

p.s. I put theme="" in the header because I have themes set in the web
config and I wanted to avoid that, you can take it out if you want.
--
Mohamad Elarabi
MCP, MCTS, MCPD.


"gnewsgroup" wrote:

> On Dec 21, 2:57 pm, Mohamad Elarabi [MCPD]
> wrote:
> > You must set Response.Buffer = False for response to go to the client
> > immediately. Please read my previous post.
> >
> > Thanks,
> > --
> > Mohamad Elarabi
> > MCP, MCTS, MCPD.
> >
>
> Yes, Mohamad, thank you. I did set Response.Buffer= false; But it
> does not work as expected.
>

Re: Console-ish output in a browser, how?

am 22.12.2007 02:05:38 von gnewsgroup

On Dec 21, 6:10 pm, Mohamad Elarabi [MCPD]
wrote:
> This code works on my box:
>
> <%@ Page Language="VB" Theme="" AutoEventWireup="false" title="Untitled
> Page" %>
>
> <%
> Response.Buffer = False
>
> System.Threading.Thread.Sleep(2000)
> Response.Write(Now & "
")
> System.Threading.Thread.Sleep(2000)
> Response.Write(Now & "
")
> System.Threading.Thread.Sleep(2000)
> Response.Write(Now & "
")
> %>
>
> And this is the output:
>
> 12/21/2007 3:03:34 PM
12/21/2007 3:03:36 PM
12/21/2007 3:03:38 PM

>
> And this is how it looks in the browser:
>
> 12/21/2007 3:03:34 PM
> 12/21/2007 3:03:36 PM
> 12/21/2007 3:03:38 PM
>
> It did write it out 2 seconds at a time.
> Are you doing this in one of the page events? Maybe you have to do it inline
> to work. Let me know if this works for you.
>
> Thanks,
>
> p.s. I put theme="" in the header because I have themes set in the web
> config and I wanted to avoid that, you can take it out if you want.
> --
> Mohamad Elarabi
> MCP, MCTS, MCPD.
>
> "gnewsgroup" wrote:
> > On Dec 21, 2:57 pm, Mohamad Elarabi [MCPD]
> > wrote:
> > > You must set Response.Buffer = False for response to go to the client
> > > immediately. Please read my previous post.
>
> > > Thanks,
> > > --
> > > Mohamad Elarabi
> > > MCP, MCTS, MCPD.
>
> > Yes, Mohamad, thank you. I did set Response.Buffer= false; But it
> > does not work as expected.

Aha, I tried your code. It indeed works. And as you said, I was indeed
trying to do it in code-behind in Page_Load.

It won't work if I try to update the Text of a Label control in the
code-behind.

Re: Console-ish output in a browser, how?

am 22.12.2007 02:08:16 von gnewsgroup

On Dec 21, 8:05 pm, gnewsgroup wrote:
> On Dec 21, 6:10 pm, Mohamad Elarabi [MCPD]
>
>
>
> wrote:
> > This code works on my box:
>
> > <%@ Page Language="VB" Theme="" AutoEventWireup="false" title="Untitled
> > Page" %>
>
> > <%
> > Response.Buffer = False
>
> > System.Threading.Thread.Sleep(2000)
> > Response.Write(Now & "
")
> > System.Threading.Thread.Sleep(2000)
> > Response.Write(Now & "
")
> > System.Threading.Thread.Sleep(2000)
> > Response.Write(Now & "
")
> > %>
>
> > And this is the output:
>
> > 12/21/2007 3:03:34 PM
12/21/2007 3:03:36 PM
12/21/2007 3:03:38 PM

>
> > And this is how it looks in the browser:
>
> > 12/21/2007 3:03:34 PM
> > 12/21/2007 3:03:36 PM
> > 12/21/2007 3:03:38 PM
>
> > It did write it out 2 seconds at a time.
> > Are you doing this in one of the page events? Maybe you have to do it inline
> > to work. Let me know if this works for you.
>
> > Thanks,
>
> > p.s. I put theme="" in the header because I have themes set in the web
> > config and I wanted to avoid that, you can take it out if you want.
> > --
> > Mohamad Elarabi
> > MCP, MCTS, MCPD.
>
> > "gnewsgroup" wrote:
> > > On Dec 21, 2:57 pm, Mohamad Elarabi [MCPD]
> > > wrote:
> > > > You must set Response.Buffer = False for response to go to the client
> > > > immediately. Please read my previous post.
>
> > > > Thanks,
> > > > --
> > > > Mohamad Elarabi
> > > > MCP, MCTS, MCPD.
>
> > > Yes, Mohamad, thank you. I did set Response.Buffer= false; But it
> > > does not work as expected.
>
> Aha, I tried your code. It indeed works. And as you said, I was indeed
> trying to do it in code-behind in Page_Load.
>
> It won't work if I try to update the Text of a Label control in the
> code-behind.

Actually, it won't work even if I try to update the Text of a Label
control in the same aspx file (not in code-behind).

Re: Console-ish output in a browser, how?

am 22.12.2007 03:55:00 von MohamadElarabiMCPD

Yes, definitely. That is because Server controls (ones with runat=server) are
not rendered as the page loads part by part. They are rendered in their
entirety and then sent to the browser. Also the whole rendering process
happens after the page_load event.

The response object is sort of like an open channel or pipe to the client
and anywhere within the page's lifetime you can response.write things but
controls are different.

This code can be in the page_Load event and it should work, I've tested it,
but it might get erased or make your page look weird depending on what you're
doing after this.

Let me know if you still need help or this is good for you.

--
Mohamad Elarabi
MCP, MCTS, MCPD.


"gnewsgroup" wrote:

> On Dec 21, 8:05 pm, gnewsgroup wrote:
> > On Dec 21, 6:10 pm, Mohamad Elarabi [MCPD]
> >
> >
> >
> > wrote:
> > > This code works on my box:
> >
> > > <%@ Page Language="VB" Theme="" AutoEventWireup="false" title="Untitled
> > > Page" %>
> >
> > > <%
> > > Response.Buffer = False
> >
> > > System.Threading.Thread.Sleep(2000)
> > > Response.Write(Now & "
")
> > > System.Threading.Thread.Sleep(2000)
> > > Response.Write(Now & "
")
> > > System.Threading.Thread.Sleep(2000)
> > > Response.Write(Now & "
")
> > > %>
> >
> > > And this is the output:
> >
> > > 12/21/2007 3:03:34 PM
12/21/2007 3:03:36 PM
12/21/2007 3:03:38 PM

> >
> > > And this is how it looks in the browser:
> >
> > > 12/21/2007 3:03:34 PM
> > > 12/21/2007 3:03:36 PM
> > > 12/21/2007 3:03:38 PM
> >
> > > It did write it out 2 seconds at a time.
> > > Are you doing this in one of the page events? Maybe you have to do it inline
> > > to work. Let me know if this works for you.
> >
> > > Thanks,
> >
> > > p.s. I put theme="" in the header because I have themes set in the web
> > > config and I wanted to avoid that, you can take it out if you want.
> > > --
> > > Mohamad Elarabi
> > > MCP, MCTS, MCPD.
> >
> > > "gnewsgroup" wrote:
> > > > On Dec 21, 2:57 pm, Mohamad Elarabi [MCPD]
> > > > wrote:
> > > > > You must set Response.Buffer = False for response to go to the client
> > > > > immediately. Please read my previous post.
> >
> > > > > Thanks,
> > > > > --
> > > > > Mohamad Elarabi
> > > > > MCP, MCTS, MCPD.
> >
> > > > Yes, Mohamad, thank you. I did set Response.Buffer= false; But it
> > > > does not work as expected.
> >
> > Aha, I tried your code. It indeed works. And as you said, I was indeed
> > trying to do it in code-behind in Page_Load.
> >
> > It won't work if I try to update the Text of a Label control in the
> > code-behind.
>
> Actually, it won't work even if I try to update the Text of a Label
> control in the same aspx file (not in code-behind).
>

Re: Console-ish output in a browser, how?

am 22.12.2007 04:52:00 von MohamadElarabiMCPD

As for making this look presentable among the rest of your page you can have
it load into an iFrame that has no borders. Your main page (default.aspx for
argument sake) will look like a normal presentable page while in it there
will be an iFrame that defaults to about:blank and has no borders, it is
undetectable. In the clientside OnLoad event of the default.aspx page you
will change the src of the iFrame to your consolish page and voila. You can
also go to town and make the onload event of the consolish page change the
display to none on the iFrame itself using the window.parent object, this way
when the process is done the consolish stuff dissappear.

--
Mohamad Elarabi
MCP, MCTS, MCPD.


"gnewsgroup" wrote:

> On Dec 21, 8:05 pm, gnewsgroup wrote:
> > On Dec 21, 6:10 pm, Mohamad Elarabi [MCPD]
> >
> >
> >
> > wrote:
> > > This code works on my box:
> >
> > > <%@ Page Language="VB" Theme="" AutoEventWireup="false" title="Untitled
> > > Page" %>
> >
> > > <%
> > > Response.Buffer = False
> >
> > > System.Threading.Thread.Sleep(2000)
> > > Response.Write(Now & "
")
> > > System.Threading.Thread.Sleep(2000)
> > > Response.Write(Now & "
")
> > > System.Threading.Thread.Sleep(2000)
> > > Response.Write(Now & "
")
> > > %>
> >
> > > And this is the output:
> >
> > > 12/21/2007 3:03:34 PM
12/21/2007 3:03:36 PM
12/21/2007 3:03:38 PM

> >
> > > And this is how it looks in the browser:
> >
> > > 12/21/2007 3:03:34 PM
> > > 12/21/2007 3:03:36 PM
> > > 12/21/2007 3:03:38 PM
> >
> > > It did write it out 2 seconds at a time.
> > > Are you doing this in one of the page events? Maybe you have to do it inline
> > > to work. Let me know if this works for you.
> >
> > > Thanks,
> >
> > > p.s. I put theme="" in the header because I have themes set in the web
> > > config and I wanted to avoid that, you can take it out if you want.
> > > --
> > > Mohamad Elarabi
> > > MCP, MCTS, MCPD.
> >
> > > "gnewsgroup" wrote:
> > > > On Dec 21, 2:57 pm, Mohamad Elarabi [MCPD]
> > > > wrote:
> > > > > You must set Response.Buffer = False for response to go to the client
> > > > > immediately. Please read my previous post.
> >
> > > > > Thanks,
> > > > > --
> > > > > Mohamad Elarabi
> > > > > MCP, MCTS, MCPD.
> >
> > > > Yes, Mohamad, thank you. I did set Response.Buffer= false; But it
> > > > does not work as expected.
> >
> > Aha, I tried your code. It indeed works. And as you said, I was indeed
> > trying to do it in code-behind in Page_Load.
> >
> > It won't work if I try to update the Text of a Label control in the
> > code-behind.
>
> Actually, it won't work even if I try to update the Text of a Label
> control in the same aspx file (not in code-behind).
>

Re: Console-ish output in a browser, how?

am 22.12.2007 05:00:28 von gnewsgroup

On Dec 21, 9:55 pm, Mohamad Elarabi [MCPD]
wrote:
> Yes, definitely. That is because Server controls (ones with runat=server) are
> not rendered as the page loads part by part. They are rendered in their
> entirety and then sent to the browser. Also the whole rendering process
> happens after the page_load event.
>
> The response object is sort of like an open channel or pipe to the client
> and anywhere within the page's lifetime you can response.write things but
> controls are different.
>
> This code can be in the page_Load event and it should work, I've tested it,
> but it might get erased or make your page look weird depending on what you're
> doing after this.
>
> Let me know if you still need help or this is good for you.
>
> --
> Mohamad Elarabi
> MCP, MCTS, MCPD.
>

OK, great. The event-firing order helps me understand why Label
controls don't work like what I want.

I do want to display such progress info in a well-formatted page. I
think that I can output formating HTML markups through
Response.Write(...). A little awkward, but maybe a solution.

Also, I think this effect can be achieved through javascript. I tried
a code snippet found from the web, which tries to update an HTML label
through something like

document.getElementById('the_id_of_the_html_label').innerHtm l =
"Saving blah blah...";
setTimeOut(.....);
document.getElementById('the_id_of_the_html_label').innerHtm l =
"Something else do display ...";

But, it did not work. I am new to javascript, and I am not sure how
to do this on the client-side.

Thank you once again.