Condividi tramite


ScriptObject.GetProperty Method (String)

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

Gets the value of 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 Function GetProperty ( _
    name As String _
) As Object
public virtual Object GetProperty(
    string name
)

Parameters

Return Value

Type: System.Object
A null reference (Nothing in Visual Basic) if the property does not exist or if the underlying ScriptObject is a managed type.

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).

Remarks

Return values follow the rules for returning types from JavaScript to managed code using by-reference marshaling rules. For more information, see Returning or Passing Managed Types to JavaScript.

The actual type of the return value is always a string, a primitive type, or a ScriptObject reference. If the underlying value of the requested property is a managed type (other than a derivation of ScriptObject), you can use the ManagedObject property to get the underlying managed type reference.

If the underlying ScriptObject is a managed type, it is not possible to get either scriptable managed methods or scriptable event properties (that is, properties with the event keyword). In both cases, this method returns nulla null reference (Nothing in Visual Basic).

Examples

The following example shows how you can access individual items in a ScriptObject that contains a JavaScript dictionary.

// Gets the sixth item in a simple JavaScript array.
GetProperty("5");
// Gets the item with the key "address" from a simple JavaScript dictionary.
GetProperty("address")

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.