Some things don't work in JScript Engine

Mar 6, 2014 at 4:29 PM
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
Coordinator
Mar 6, 2014 at 5:04 PM
Hello shripaldalal,

Could you try renaming "this"? It's a reserved word in JavaScript.

Thanks!
Marked as answer by shripaldalal on 3/6/2014 at 7:49 PM
Mar 6, 2014 at 5:17 PM
Worked. Sorry for disturbing you over something so trivial! Thanks for your help!