System.Windows.Forms.WebBrowser.DocumentText Property

Gets or sets the HTML contents of the page displayed in the System.Windows.Forms.WebBrowser control.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.Browsable(false)]
public string DocumentText { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

Use this property when you want to manipulate the contents of an HTML page displayed in the System.Windows.Forms.WebBrowser control using string processing tools. You can use this property, for example, to load pages from a database or to analyze pages using regular expressions. When you set this property, the System.Windows.Forms.WebBrowser control automatically navigates to the about:blank URL before loading the specified text. This means that the WebBrowser.Navigating, WebBrowser.Navigated, and WebBrowser.DocumentCompleted events occur when you set this property, and the value of the WebBrowser.Url property is no longer meaningful.

Note:

This property contains the text of the current document, even if another document has been requested. If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the System.Windows.Forms.WebBrowser control has not had time to load the new content. You can retrieve the new value in a WebBrowser.DocumentCompleted event handler. Alternatively, you can block the thread until the document is loaded by calling the erload:System.Threading.Thread.Sleep method in a loop until the WebBrowser.DocumentText property returns the value that you originally set it to.

To access the contents of a Web page as a System.IO.Stream, use the WebBrowser.DocumentStream property. You can also access the page contents using the HTML document object model (DOM) through the WebBrowser.Document property.

Requirements

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