Freigeben über


ScriptObject.SetProperty Method (String, Object)

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

Sets a property that is identified by name on the current scriptable object.

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

Syntax

'Declaration
Public Overridable Sub SetProperty ( _
    name As String, _
    value As Object _
)
public virtual void SetProperty(
    string name,
    Object value
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

name is nulla null reference (Nothing in Visual Basic).

ArgumentException

name is an empty string.

-or-

name contains an embedded null character (\0).

InvalidOperationException

A type mismatch exists between the supplied type and the target property.

-or-

The property is not settable.

-or-

All other failures.

Remarks

The possible types for value follow the rules for passing managed types to JavaScript using by-reference marshaling rules. For more information, see Returning or Passing Managed Types to JavaScript.

It is possible to set a property value for a non-existing property. In this case, the browser adds the property as an expando on the object.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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