我已经在后面的代码中动态生成了一个网页。如何在用户桌面上加载并显示它?(C#,asp.net)
这是我的代码:

       StringBuilder strHtm = new StringBuilder();


        strHtm.Append("<html>");
        strHtm.Append(Environment.NewLine);

        strHtm.Append("<head>");
        strHtm.Append(Environment.NewLine);
        strHtm.Append("<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
        strHtm.Append(Environment.NewLine);

       strHtm.Append("</head>");
        strHtm.Append(Environment.NewLine);

        strHtm.Append("<body>");
        strHtm.Append(Environment.NewLine);

         //some code here reading from datatable

        strHtm.Append("</body>");
        strHtm.Append(Environment.NewLine);

        strHtm.Append("</html>");
        strHtm.Append(Environment.NewLine);


现在如何在浏览器的新标签页或窗口中加载它?

最佳答案

添加另一个asp页面
将PlaceHolder添加到新创建的ASP页面
删除html,head,body标签
最后在page_load中添加这一行代码

PlaceHolder1.Controls.Add(new LiteralControl(strHtm.ToString().Trim()))

10-04 15:23