Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Response.Flush();

Posted on 2004-04-12
12
Medium Priority
?
771 Views
Last Modified: 2008-02-01
why when i run or step trough this code, the html added to the page does not show at the moment of  Thread.Sleep?  thank you.

            placeholder.Controls.Clear();

                  string HTML = "";
                  HTML = "<table><tr><td>test</td></tr></table>";
            
                  Control objControl = this.Page.ParseControl(HTML);
                  this.placeholder.Controls.Add(objControl);


                  //Response.Clear();
                  Response.Buffer= true;
                  Response.Flush();
                  this.placeholder.Visible = true;
                  Thread.Sleep(15000);
0
Comment
Question by:alain123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
12 Comments
 
LVL 12

Accepted Solution

by:
monosodiumg earned 750 total points
ID: 10805348
I think it's because you have flushed BEFORE you set the placeholder to visible. If it's not visible, it may not generate any HTML.
I'm assuming this is after PreRender. In it's before PreREnder, then it won't have gotten round to generating the HTML.
0
 
LVL 1

Author Comment

by:alain123
ID: 10805602
hello, i'm doing this after InOnit() ... before pre-render.. i tried to change the this.placeholder.Visible = true; before flush(), but nothing.. still the same form..
0
 
LVL 12

Expert Comment

by:monosodiumg
ID: 10805642
Then you are nto going to see any HTML in the output because none has been generated. yet.
Why are you flushing in OnInit? At that stage you have pretty much nothing to flush.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:alain123
ID: 10805679
no I'm not flushing inside OnInit().. but After.. I'm flushing inside a Button_Onclick() event  that it's called after OnInit()... and

"Then you are nto going to see any HTML in the output because none has been generated. yet" ..I'm adding the html to the control .. i think it should  be there, unless i'm not doind some kind of refreshing..

               HTML = "<table><tr><td>test</td></tr></table>";
         
               Control objControl = this.Page.ParseControl(HTML);
               this.placeholder.Controls.Add(objControl);
0
 
LVL 12

Expert Comment

by:monosodiumg
ID: 10808979
Sorry alain, I've had very littel exposure to the finer points of using controls so I can't help.
0
 
LVL 1

Author Comment

by:alain123
ID: 10809150
Thank you mon, for your help, i appreaciate it.
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 10811177
Before the render method no html will be written to the output stream therefore Response.Flush() does not change anything. Response.Buffer should be changed in the beginning of the pages lifecycle so that either all contents or nothing is buffered.
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 10811195
Place this code in OnPreRender:

              placeholder.Controls.Clear();

               string HTML = "";
               HTML = "<table><tr><td>test</td></tr></table>";
         
               Control objControl = this.Page.ParseControl(HTML);
               this.placeholder.Controls.Add(objControl);
               Response.Buffer= true;

Place this code in the overriden Render method:

               this.placeholder.Visible = true;
               Response.Flush();
               Thread.Sleep(15000);
0
 
LVL 10

Assisted Solution

by:ptmcomp
ptmcomp earned 750 total points
ID: 10811204
Argh! The Visible property needs also to be set in the prerender method - else Render() will not produce any html.
0
 
LVL 5

Expert Comment

by:AdrianJMartin
ID: 10811770
this works and you see the page 'filling up", it seams the Reponse object does not recognise the setting of Buffer to true until it has flushed the response automatically, I just pushed 300 spaces onto the stream as a test and it works.

            private void Button1_Click(object sender, System.EventArgs e)
            {
                  Response.Buffer= true;

//                  Response.Write( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789<br>" );
                  Response.Write( "                                                                                                        " );
                  Response.Write( "                                                                                                        " );
                  Response.Write( "                                                                                                        " );

                  Response.Flush();


                  Response.Write("test2");
                  for( int i = 0  ; i < 100 ; i ++ )
                  {
                        
                        Response.Write( string.Format("Message {0}<br>" , i ) ) ;
                        Response.Flush();
                        System.Threading.Thread.Sleep(100);
                  }
            }
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question