I have a third-party tool that creates an img tag through code using the HtmlTextWriter RenderBeginTag, RenderEndTag and AddAttribute methods. I want to get the resulting HTML in a string. I tried the reflection method mentioned here , but I get the error “Unable to overlay object of type“ System.Web.HttpWriter ”on type“ System.IO.StringWriter. ”InnerWriter type HtmlTextWriter has type HttpWriter.
Any ideas on how to copy the html output file to a string?
Addition: code from a third-party control
protected override void Render( HtmlTextWriter output ) { ..... output.AddAttribute( HtmlTextWriterAttribute.Src, src ); output.RenderBeginTag( HtmlTextWriterTag.Img ); output.RenderEndTag(); <-- What is the HTML now? Maybe look in OnPreRenderComplete event? }
Tony_henrich
source share