开发者

How to preview a html file without saving it?

开发者 https://www.devze.com 2023-02-01 00:24 出处:网络
Hy, In my application I store a s开发者_如何学运维tring as content of a html file. How can I preview this content (assuming that it\'s modified from original content) in browser but not having to s

Hy,

In my application I store a s开发者_如何学运维tring as content of a html file.

How can I preview this content (assuming that it's modified from original content) in browser but not having to save it local.

Update

And the preview to be in another tab or window.


You can create a preview page that just writes the html string to the response like so:

    protected void Page_Load(object sender, EventArgs e)
    {
        string htmlString = //initialise the string here
        Response.Write(htmlString);
        Response.End();
    }


Using the Control System.Windows.Forms.WebBrowser, you can preview your HTML with DocumentText

Example:

webBrowser1.DocumentText = "<HTML><BODY style=\" background-color:black\"></BODY></HTML>";
0

精彩评论

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