Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight
Silverlight 3
HtmlWindow Class
HtmlWindow Methods
 Eval Method
Collapse All/Expand All Collapse All
.NET Framework Class Library for Silverlight
HtmlWindow..::.Eval Method

Evaluates a string that contains arbitrary JavaScript code.

Namespace:  System.Windows.Browser
Assembly:  System.Windows.Browser (in System.Windows.Browser.dll)
Visual Basic (Declaration)
Public Function Eval ( _
    code As String _
) As Object
Visual Basic (Usage)
Dim instance As HtmlWindow
Dim code As String
Dim returnValue As Object

returnValue = instance.Eval(code)
C#
public Object Eval(
    string code
)

Parameters

code
Type: System..::.String
JavaScript code.

Return Value

Type: System..::.Object
The results of the JavaScript engine's evaluation of the string in the code parameter.
ExceptionCondition
ArgumentNullException

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

ArgumentException

code is an empty string.

InvalidOperationException

An unexpected error occurred.

The Eval method passes the specified code to the browser's JavaScript engine to parse and execute. If a return value is created as a result, it is marshaled back to managed code by using the heuristics described in Passing JavaScript Objects to Managed Code. The return value follows the same restrictions and conventions as the ScriptObject..::.Invoke method.

The Firefox and Safari browsers do not propagate errors that occur as a result of calling the Eval method. If you require error information in Firefox or Safari, you should include custom error handling in the code parameter. For example, the following code example permits error information to be marshaled back to managed code.

HtmlPage.Window.Eval("try { //do some work here }
                      catch (e) { e.message ? e.message : e; }"
                    );

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker