Getting HTML from Control.Render
-
I can get a Control to Render its HTML output to an HtmlTextWriter, but I am unable to get the HtemlTextWriter to give me the HTML string that it contains. Nor can I figure out from the documentation how to access the output stream object the writer references so that I can get the HTML from the original control. Any ideas? Thanks in advance. Dan Morris
-
I can get a Control to Render its HTML output to an HtmlTextWriter, but I am unable to get the HtemlTextWriter to give me the HTML string that it contains. Nor can I figure out from the documentation how to access the output stream object the writer references so that I can get the HTML from the original control. Any ideas? Thanks in advance. Dan Morris
Here's one way:
HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());
control.RenderControl(writer);string html = writer.InnerWriter.ToString();
Regards, Alvaro
-
Here's one way:
HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());
control.RenderControl(writer);string html = writer.InnerWriter.ToString();
Regards, Alvaro
Thanks. I'll give it a try. Dan Morris
-
Here's one way:
HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());
control.RenderControl(writer);string html = writer.InnerWriter.ToString();
Regards, Alvaro
That worked. Thanks! Dan Morris