473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

RenderControl not writing complete markup

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
1 2842
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: B. Tommie Usdin | last post by:
--------------------------------------------------------- ************* Complete Program Available ************** ************ Late Breaking News Added ************* *********** Extreme...
5
by: Mario | last post by:
I would like to author stylized web content using custom cascading style sheets. I want to be able to type the document with the mindset of a writer and momentarily forget that I am authoring web...
6
by: Christopher Benson-Manica | last post by:
I have some markup like the following: <form> <table> <script> <!-- Write the table markup //--> </script> </table> <form>
385
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like...
17
by: Eric Lindsay | last post by:
Is learning to write CSS a better use of time than finding and using a package that produces complete web pages? I've moved to a new platform (Macintosh), taking with me about 400 personal web...
2
by: George Ter-Saakov | last post by:
I am trying to wrap PlaceHolder so it will output prefix/suffix (like <div>, </div>) before render the actual control. So i created public class clsSection : PlaceHolder protected override...
1
by: Peter Kirk | last post by:
Hi, if I am writing a web custom control, do I override the Render method or the RenderControl method - and what is the difference? Thanks, Peter
0
drhowarddrfine
by: drhowarddrfine | last post by:
I see these mistakes over and over again. Follow them and you can get a quicker and better answer to your questions. Include a link to your page or the complete HTML and CSS. A picture of the...
0
by: wagswvu | last post by:
I am writing a User Control in C# that dynamically generates some text boxes and two buttons. For all the html on the page I am overriding the render method, I also render my Button/Textbox controls...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.