WebBrowser.Navigate Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Loads the HTML content at the specified URI.

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

Syntax

'Declaration
Public Sub Navigate ( _
    source As Uri _
)
public void Navigate(
    Uri source
)

Parameters

  • source
    Type: System.Uri
    The URI of the HTML content to load.

Remarks

The specified URI can be fully qualified or be a relative URI. When you set use a relative URI you should use the following convention:

  • "/Page1.html" is an application level resource that gets resolved to the base URI of the application (XAP file). This means the relative URI must resolve to the same site of origin as the application.

You cannot specify a URL to an embedded or local resource.

Examples

The following example shows a WebBrowser with its Source property set to an HTML page. In a button event handler, the WebBrowser source is changed to a different HTML page by calling the Navigate(Uri) method. The host Silverlight application must be running outside the browser or in an in-browser trusted application for this example to function correctly.

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.Windows.RoutedEventArgs)
    WB1.Navigate(New Uri("https://localhost/HTMLPage2.htm"))

private void Button1_Click(object sender, RoutedEventArgs e)
{
    WB1.Navigate(new Uri("https://localhost/HTMLPage2.htm"));

}
<TextBlock Text="WebBrowser Control" />
<WebBrowser Source="https://localhost/HTMLPage1.html" Height="160" Width="160" x:Name="WB1"/>
<Button Width="200" x:Name="Button1" Content="Click for HTML content" Click="Button1_Click"   />

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.