Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Some things don't work in JScript Engine

$
0
0
Hi,

I don't know if I am doing something wrong or its a bug but just thought I will post if for your information. Following works in VBScript engine but not in JScript engine.
Imports System.Xml
Imports Microsoft.ClearScript

Public Class WebForm1
    Inherits System.Web.UI.Page

    Public vbs As Windows.VBScriptEngine = New Windows.VBScriptEngine
    Public js As Windows.JScriptEngine = New Windows.JScriptEngine

    Public xml As XmlDocument = New XmlDocument
    Public search As XmlNodeList, this As XmlNode

    Public Sub Initialize()
        js.AddRestrictedHostObject("me", HostItemFlags.GlobalMembers, Me)
        vbs.AddRestrictedHostObject("me", HostItemFlags.GlobalMembers, Me)

        xml.LoadXml("<sales><row><product>watch</product><rate>100</rate></row><row><product>laptop</product><rate>600</rate></row></sales>")

        Try
            search = xml.SelectNodes("//product")
            For Each Me.this In search
                js.Execute("Response.Write(this.InnerText);")
                Response.Write("<BR>")
                vbs.Execute("response.write this.innertext")
                Response.Write("<BR>")
            Next

        Catch ex As Exception
            Response.Write(ex)
        End Try

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
End Class
The output is as:
[undefined]
watch
[undefined]
thermos

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>