Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Add variables


Thanks a ton for the quick reply. Worked like a charm. Though I did this, so all the objects of the class get added in script global. Which is exactly what I need. As I mentioned in the other thread, I will be having one web class = 1 script engine! If you feel this is wrong please let me know or I will go ahead using this.

Imports System.Xml
Imports Microsoft.ClearScript

Public Class WebForm1
Inherits System.Web.UI.Page

Public xml As XmlDocument = New XmlDocument
Public documentid As Integer = New Integer
Public cs_engine As Windows.JScriptEngine = New Windows.JScriptEngine

Public Sub Initialize()
documentid = 1
cs_engine.AddRestrictedHostObject("me", HostItemFlags.GlobalMembers, Me)

    cs_engine.Execute("xml.LoadXml('<sales id=""123""/>');")
    cs_engine.Execute("documentid = documentid + 1;")

Catch e As Microsoft.ClearScript.ScriptEngineException
End Try

If xml.InnerXml.ToString <> "" Then
    Response.Write(xml.SelectSingleNode("//sales").Attributes.GetNamedItem("id").InnerText & "<BR><BR>")
    Response.Write("No XML Detected!<br><br>")
End If

End Sub

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

End Sub
End Class

Viewing all articles
Browse latest Browse all 2297