Programming Microsoft Web Forms (Pro Developer)
WebBrowser Control Details
In addition to the one property of the WebBrowser control that we have already seen, the Url property, the WebBrowser control exposes a variety of other properties, events, and methods. The most important of these are shown in Table 8-1.
Member Name | Description |
---|---|
AllowNavigation | A property that gets or sets a value indicating whether the control can navigate to a different page after its initial page is loaded. |
AllowWebBrowserDrop | A property that gets or sets a value indicating whether the WebBrowser control navigates to documents dropped onto it. |
CanGoBack , CanGoForward | Properties that get values indicating whether the WebBrowser control can go back or forward. |
Document | A property that gets a System.Windows.Forms.HtmlDocument object representing the Web page currently displayed in the WebBrowser control. The HtmlDocument object gives the developer access to the Document Object Model (DOM) of the page currently loaded in the WebBrowser control. |
DocumentText | A property that gets or sets the HTML text of the WebBrowser control. By using this property, you can completely examine the text retrieved from a Web site. By using a WebBrowser control with the Visible property set to false, a developer can use the DocumentText property to do what is commonly known as screen scraping, or retrieving values from a Web page. |
IsBusy | A property that gets a value indicating whether the WebBrowser control is currently loading a new document. |
IsOffline | A property that gets or sets a value indicating whether the WebBrowser control is in offline mode. |
ScriptErrorsSuppressed | A property that gets or sets a value indicating whether script errors display a dialog box that indicates the error. |
Url | A property that gets or sets the value of the URL of the current document. |
DocumentCompleted | An event that occurs when the WebBrowser control completes the loading of a document. |
FileDownload | An event that occurs before the WebBrowser control downloads a file. This event can be used to disable file downloads by canceling them. |
Navigated | An event that occurs when the WebBrowser control has navigated to a new page and has begun downloading it. |
Navigating | An event that occurs before the WebBrowser control navigates to a new page. |
NewWindow | An event that occurs before a new browser window is opened. Note that new windows opened by right-clicking a link in the WebBrowser control and selecting Open In A New Window will open in a new Internet Explorer window. Intercepting this event can allow you to handle the new page in some other way. |
ProgressChanged | An event that occurs when the control has updated information about the progress of the document being loaded. Thisevent can be used to provide a progress bar for page loads. |
GoBack, GoForward | Methods that navigate to the previous or next page in the navigation history, if one exists. |
Navigate | A method that loads a document specified by a parameter to this method. |
| A method that prints the document currently displayed in the WebBrowser control using the default settings. |
Refresh | A method that reloads the current document in the WebBrowser control. |
ShowPrintDialog | A method that opens the Internet Explorer Print dialog box. |
ShowPrintPreviewDialog | A method that opens the Internet Explorer Print Preview dialog box. |
ShowSaveAsDialog | A method that opens the Internet Explorer Save As dialog box. |
Stop | A method that cancels the loading of any pending document. |
Note | The WebBrowser control also exposes a large number of other properties, methods, and events that are common to all Windows controls. The members shown in Table 8-1 are properties specific to the WebBrowser class. |