Export (0) Print
Expand All

WebBrowser::Navigated Event

Occurs when the WebBrowser control has navigated to a new document and has begun loading it.

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

public:
 event WebBrowserNavigatedEventHandler^ Navigated {
	void add (WebBrowserNavigatedEventHandler^ value);
	void remove (WebBrowserNavigatedEventHandler^ value);
}

The WebBrowser control navigates to a new document whenever one of the following properties is set or methods is called:

Handle the Navigated event to receive notification when the WebBrowser control has navigated to a new document. When the Navigated event occurs, the new document has begun loading, which means you can access the loaded content through the Document, DocumentText, and DocumentStream properties. Handle the DocumentCompleted event to receive notification when the WebBrowser control finishes loading the new document.

You can also receive notification before navigation begins by handling the Navigating event. Handling this event lets you cancel navigation if certain conditions have not been met, for example, the user has not completely filled out a form.

For more information about handling events, see Handling and Raising Events.

The following code example demonstrates how to use a handler for the Navigated event to implement an address bar for the WebBrowser control. This example requires that your form contains a WebBrowser control called webBrowser1, a TextBox control called TextBoxAddress, and a Button control called ButtonGo. When you type a URL into the text box and press ENTER or click the Go button, the WebBrowser control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL.

For the complete code example, see How to: Add Web Browser Capabilities to a Windows Forms Application.

   // Navigates to the URL in the address text box when  
   // the ENTER key is pressed while the text box has focus. 
   void TextBoxAddress_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
   {
      if ( e->KeyCode == System::Windows::Forms::Keys::Enter &&  !this->TextBoxAddress->Text->Equals( "" ) )
      {
         this->WebBrowser1->Navigate( this->TextBoxAddress->Text );
      }
   }

   // Navigates to the URL in the address text box when  
   // the Go button is clicked. 
   void ButtonGo_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      if (  !this->TextBoxAddress->Text->Equals( "" ) )
      {
         this->WebBrowser1->Navigate( this->TextBoxAddress->Text );
      }
   }

   // Updates the URL in TextBoxAddress upon navigation. 
   void WebBrowser1_Navigated( Object^ /*sender*/, System::Windows::Forms::WebBrowserNavigatedEventArgs^ /*e*/ )
   {
      this->TextBoxAddress->Text = this->WebBrowser1->Url->ToString();
   }

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft