How to retrieve the rendered html for a control in ASP.NET?
How do I retrieve the html rendered for a web control in ASP .NET programmatically?
For instance something like:
dim controlHTML as string = myControl.GetHTML(开发者_开发技巧)
System.Text.StringBuilder sb = new System.Text.StringBuilder();
using (System.IO.StringWriter sw = new System.IO.StringWriter(sb))
using (System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw))
{
mycontrol.RenderControl(hw);
}
You have to actually call it's .RenderMethod, and pass in a HtmlTextWriter, and get the contents from that.
精彩评论