Export (0) Print
Expand All
1 out of 3 rated this helpful - Rate this topic

WebBrowser::ObjectForScripting Property

Gets or sets an object that can be accessed by scripting code that is contained within a Web page displayed in the WebBrowser control.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[BrowsableAttribute(false)]
public:
property Object^ ObjectForScripting {
	Object^ get ();
	void set (Object^ value);
}

Property Value

Type: System::Object
The object being made available to the scripting code.
ExceptionCondition
ArgumentException

The specified value when setting this property is an instance of a non-public type.

-or-

The specified value when setting this property is an instance of a type that is not COM-visible. For more information, see Marshal::IsTypeVisibleFromCom.

Use this property to enable communication between a Web page hosted by the WebBrowser control and the application that contains the WebBrowser control. This property lets you integrate dynamic HTML (DHTML) code with your client application code. The object specified for this property is available to Web page script as the window.external object, which is a built-in DOM object provided for host access.

You can set this property to any COM-visible object for which you want its public properties and methods available to scripting code. You can make a class COM-visible by marking it with the ComVisibleAttribute.

To call functions defined in your Web page from your client application code, use the HtmlDocument::InvokeScript method of the HtmlDocument object you can retrieve from the Document property.

The following code example demonstrates how to use the ObjectForScripting property. In the example, the ObjectForScripting property is set to the current form.

No code example is currently available or this language may not be supported.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.