Getting "To Render" HTML from WebControl into String

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After I have instanced a webcontrol (in code) and set its properties, I would
like to get the html that it would render to the display. Can this be done.
How???

Earl
 
Hello Earl,

StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);

using (HtmlTextWriter writer = new HtmlTextWriter(sw))
{
myControl.RenderControl(writer);
}

string html = sb.ToString();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top