By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,092 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,092 IT Pros & Developers. It's quick & easy.

RenderControl not writing complete markup

P: n/a
I have a GridView which I want to send via email. I have overriden
VerifyRenderingInServerForm to allow this.
But if I call RenderControl to write the html markup in a memory stream I
only get part of the markup. If I do a subsequent call to RenderControl the
missing markup is rendered and the Control is rendered a second time (again
it stops inside the markup).

MemoryStream ms = new MemoryStream();
TextWriter tw = new StreamWriter(ms);
HtmlTextWriter htw = new HtmlTextWriter(tw);
GridView2.RenderControl(htw);

I noticed the control will only write 1024 bytes to the Memorystream. So I
had the idea of increasing the write buffer.
TextWriter tw = new StreamWriter(ms, System.Text.Encoding.UTF8, 2048);
but then there was nothing written to the stream.
After some experimenting I found out that a small increase of the buffer
will write more bytes to the stream but a larger increase will write none.
The maximum buffer size that still writes to the stream is the needed length
for the complete html markup minus one.
So, in my case
TextWriter tw = new StreamWriter(ms, System.Text.Encoding.UTF8, 1313);
will write the complete markup excluding the final >.
Are there any solutions to this (I wouldn't like to use code to get the
buffersize needed and add the final >)? This seems to be a bug...

TIA
Ralf
Apr 11 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
A good workaround is to use a StringWriter instead of a MemoryStream.

"Ralf Ziller" <no****@none.deschrieb im Newsbeitrag
news:e7**************@TK2MSFTNGP05.phx.gbl...
But if I call RenderControl to write the html markup in a memory stream I
only get part of the markup.
I noticed the control will only write 1024 bytes to the Memorystream.

Apr 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.