日期:2014-05-18  浏览次数:20518 次

如何把一个字符串StringBuilder htmltext通过button按钮在新的网页上来实现预览。
如何把一个字符串StringBuilder htmltext通过button按钮在新的网页上来实现预览。

------解决方案--------------------
方法很多,下面是其中之一

C# code
protected void Page_Load(object sender, EventArgs e)
{

    StringBuilder s = new StringBuilder();
    s.AppendLine("<h3>net_lover</h3>");
    s.AppendLine("<h3>net_lover</h3>");
    s.Append("<h3>net_lover</h3>");
    HtmlTextArea h = new HtmlTextArea();
    h.Style.Add("display", "none");
    h.Value =s.ToString();
    form1.Controls.Add(h);
    Button1.Attributes.Add("onclick", "w = window.open('');w.document.write(document.getElementById('" + h.ClientID + "').value);return false;");
}