Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HtmlDocument.Write Method

Note: This method is new in the .NET Framework version 2.0.

Writes a new HTML page.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public void Write (
	string text
)
public void Write (
	String text
)
public function Write (
	text : String
)

Parameters

text

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft