Share via

WebBrowser.NavigateToString Method

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

Displays the specified HTML content.

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


Public Sub NavigateToString ( _
    text As String _
public void NavigateToString(
    string text



The text parameter should be formatted as HTML. The text parameter can also contain JavaScript. If there are JavaScript functions contained in the HTML, you can use the InvokeScript method to call the functions from managed code. For security reasons, you should never display user-provided, and therefore untrusted, HTML using the NavigateToString method.


The following example shows how to use the NavigateToString method to display cross-domain content in an <iframe>.

Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    WB1.NavigateToString("<html><head></head><body>Silverlight Developer Site" & _
        "<iframe src="""" WIDTH=300 HEIGHT=200>" & _
End Sub
private void Button_Click(object sender, RoutedEventArgs e)
    WB1.NavigateToString("<html><head></head><body>Silverlight Developer Site" +
    "<iframe src=\"\" WIDTH=300 HEIGHT=200>" + 
    <Button Width="200" Content="Click for" Click="Button_Click"  />
    <WebBrowser Height="270" Width="400" x:Name="WB1" />

Version Information


Supported in: 5, 4


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