Displaying a session variable created in VBScript in a Javascript platform.

Posted on 2006-04-04
Last Modified: 2008-03-10


We have created a global.asa file that contains a variety of session variables that we use for this ASP.Net application.
Here is the relevant code for the global.asa page.

<script language="vbscript" runat="server">

sub Session_OnStart
      session("count") = 0
end sub

There is extra code within the code, but the key point is that it is in VBScript and needs to stay in VBScript.

session("count"), however, needs to be able to be written on a Javascript page.

The javascript page is automatically generated from a Manifold GIS application and needs to remain in Javascript.
We need to be able to Response.Write the session("count") variable on the page. However, because the
session varibale was created in a VBScript, we cannot write it on the page. We have attempted to add a VBScript section to the page to write this variable but this does not work. Here is an excerpt from the code that we think should work, but does not.

<%@ enablesessionstate=false language=javascript %>



<script language=vbscript>

Response.Write session("count")


The page displays fine, but the vbscript does not execute at all. On other pages, that are initialized with vbscript, the session variable works the way it should so we know it is not a problem with the session variable. How can we fix this problem?


Question by:SysCapstone
    LVL 29

    Expert Comment


    <script language="Javascript">
    LVL 12

    Accepted Solution

       <script language=vbscript>


        <script language=javascript>

        <%=session("count") %>
    LVL 29

    Expert Comment

    OOps yes, BSDOTNET is correct - I forgot the document.write bit
    LVL 26

    Assisted Solution

    >>The javascript page is automatically generated from a Manifold GIS application
    Is this a ".js" file? if s, then server scripts are not run within this file ..

    one way of doing this is create a variable in the javascript file and then set the value in the page where it is requried ..

    var MyCount; ( in javascript file)

    in the vb file where the count is required ..

    registerclientscriptblock("SetCount", "<script language = javascript>Mycount =" & session("Count") & ";</script>")

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now