.NET Framework Class Library for Silverlight
ScriptObject..::.Invoke Method

Invokes a method on the current scriptable object, and optionally passes in one or more method parameters.

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

Visual Basic (Declaration)
Public Overridable Function Invoke ( _
    name As String, _
    ParamArray args As Object() _
) As Object
Visual Basic (Usage)
Dim instance As ScriptObject
Dim name As String
Dim args As Object()
Dim returnValue As Object

returnValue = instance.Invoke(name, args)
C#
public virtual Object Invoke(
    string name,
    params Object[] args
)

Parameters

name
Type: System..::.String
The method to invoke.
args
Type: array<System..::.Object>[]()[]
Parameters to be passed to the method.

Return Value

Type: System..::.Object
An object that represents the return value from the underlying JavaScript method.
Exceptions

ExceptionCondition
ArgumentNullException

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

ArgumentException

name is an empty string.

-or-

name contains an embedded null character (\0).

-or-

The method does not exist or is not scriptable.

InvalidOperationException

The underlying method invocation results in an error. The .NET Framework attempts to return the error text that is associated with the error.

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 possible types for args follow the rules for passing managed types to JavaScript using by-reference marshaling rules.

If args is nullNothingnullptra null reference (Nothing in Visual Basic), it is interpreted as an empty parameter list. As a result, passing nullNothingnullptra null reference (Nothing in Visual Basic) is the same as passing new object[].

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.

Examples

The following example shows how you can access individual items in a ScriptObject that contains either a JavaScript collection or a dictionary by invoking the item property (ordinal for arrays, and key for dictionary) and passing an ordinal for a parameter.

// Fetch the sixth item in a collection.
Invoke("item",5);
// Fetch address item from dictionary.
Invoke("item","address"); 

However, this approach will not work for simple JavaScript arrays. For information about how to access an item in a simple JavaScript array, see ScriptObject..::.GetProperty.

Platforms

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

See Also

Reference

Tags :


Page view tracker