HtmlDocument.Write Method (String)


Writes a new HTML page.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public void Write(
	string text


Type: System.String

The HTML text to write into the document.

All calls to Write should be preceded by a call to OpenNew, which will clear the current document and all of its variables. Your calls to Write will create a new HTML document in its place. To change only a specific portion of the document, obtain the appropriate HtmlElement and set its InnerHtml property.

It is recommended that you write an entire valid HTML document using the Write method, including HTML and BODY tags. However, if you write just HTML elements, the Document Object Model (DOM) will supply these elements for you.

The following code example opens a new HtmlDocument and writes in a new HTML file.

private void WriteNewDocument()
    if (webBrowser1.Document != null)
        HtmlDocument doc = webBrowser1.Document.OpenNew(true);
        doc.Write("<HTML><BODY>This is a new HTML document.</BODY></HTML>");

.NET Framework
Available since 2.0
Return to top