R
Ralf Ziller
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
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