If I create a UserControl and add some objects to it, how can I grab the HTML it would render?
ex.
UserControl myControl = new UserControl();
myControl.Controls.Add(new TextBox());
// ...something happens
return strHTMLofControl;
I'd like to just convert a newly built UserControl to a string of HTML.
Answered (below):
Using azamsharp's method worked - here's the code example:
TextWriter myTextWriter = new StringWriter();
HtmlTextWriter myWriter = new HtmlTextWriter(myTextWriter);
myControl.RenderControl(myWriter);
return myTextWriter.ToString();
You'll need to be using System.IO (to get the StringWriter class).