asp.net RenderControl

 
//using System.IO;
//using System.Web;
//using System.Web.UI;
//using System.Web.UI.HtmlControls;
protected void Page_Load(object sender, EventArgs e)
{
    HtmlGenericControl test = new HtmlGenericControl("div");
    test.Controls.Add(new HtmlButton());
    HtmlAnchor anchor = new HtmlAnchor();
    anchor.HRef = "#";
    anchor.InnerText = "test";
    test.Controls.Add(anchor);

    StringWriter writer = new StringWriter();
    HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
    test.RenderControl(htmlWriter);
    Response.Write(writer.GetStringBuilder().ToString());
}
阅读更多
文章标签: asp.net object div
个人分类: C# .net与COM Web
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭