开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜