Source Property
Collapse the table of content
Expand the table of content

WebBrowser.Source Property

 

Gets or sets the Uri of the current document hosted in the WebBrowser.

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

public Uri Source {
	[SecurityCriticalAttribute]
	get;
	set;
}

Property Value

Type: System.Uri

The Uri for the current HTML document.

Exception Condition
ObjectDisposedException

The WebBrowser instance is no longer valid.

InvalidOperationException

A reference to the underlying native WebBrowser could not be retrieved.

SecurityException

Navigation from an application that is running in partial trust to a Uri that is not located at the site of origin.

Setting the source property causes WebBrowser to navigate to the document specified by the Uri. If the Uri is null, a blank document is displayed ("about:blank").

The following example shows how to configure WebBrowser to navigate to an HTML document by using markup only.

<!-- Web Browser Control that hosts a web page. -->
<WebBrowser x:Name="webBrowser" Source="http://msdn.com" 
  Width="600" Height="600"  />

.NET Framework
Available since 3.0
Silverlight
Available since 4.0
Return to top
Show:
© 2016 Microsoft