简体   繁体   中英

How to display a dynamically generated webpage to the new tab?

I have generated a webpage dynamically in code behind. How can load and display it on user desktop?(c#, asp.net) here is my code:

       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);

Now how can I load it in browser new tab or window?

  1. add another asp page
  2. add a PlaceHolder to newly created asp page
  3. remove html,head,body tags
  4. finally add this line of code in page_load

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM