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

New Post: Add variables

0
0
Hey,

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)

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

Catch e As Microsoft.ClearScript.ScriptEngineException
    Response.Write(e.GetBaseException)
End Try

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

Response.Write(documentid)
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