Use this property when you want to manipulate the contents of an HTML page displayed in the 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 WebBrowser control automatically navigates to the about:blank URL before loading the specified text. This means that the Navigating, Navigated, and DocumentCompleted events occur when you set this property, and the value of the 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
WebBrowser control has not had time to load the new content. You can retrieve the new value in a DocumentCompleted event handler. Alternatively, you can block the thread until the document is loaded by calling the Thread..::.Sleep method in a loop until the DocumentText property returns the value that you originally set it to.
|
To access the contents of a Web page as a Stream, use the DocumentStream property. You can also access the page contents using the HTML document object model (DOM) through the Document property.
Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note:
The .NET Compact Framework does not support using DocumentText to get the content of a Web page, but you can use it to present HTML to your users, such as to provide links and a simple HTML form. For a code example, see How to: Use the WebBrowser Control in the .NET Compact Framework.