ScriptObject.GetProperty Method (String)

Silverlight

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)

public virtual Object GetProperty(
	string name
)

Parameters

name
Type: System.String
The name of the property.

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.

ExceptionCondition
ArgumentNullException

name is null.

ArgumentException

name is an empty string.

-or-

name contains an embedded null character (\0).

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

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

Silverlight

Supported in: 5, 4, 3

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

Community Additions

ADD
Show: