Converting contents of HtmlTextWriter to a string

Posted by Tony_Henrich on Stack Overflow See other posts from Stack Overflow or by Tony_Henrich
Published on 2010-06-07T18:21:55Z Indexed on 2010/06/07 18:32 UTC
Read the original article Hit count: 245

Filed under:
|
|

I have a third party tool that creates an img tag through code using HtmlTextWriter's RenderBeginTag, RenderEndTag & AddAttribute methods. I want to get the resulting HTML into a string. I tried the reflection method mentioned here but I get a error "Unable to cast object of type 'System.Web.HttpWriter' to type 'System.IO.StringWriter". The InnerWriter type of the HtmlTextWriter is of type HttpWriter.

Any ideas on how to copy the output html into a string?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about ASP.NET