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


Hi,

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
      
</script>

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 %>
<%

JAVASCRIPT............

%>

<script language=vbscript>

Response.Write session("count")

</script>

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?

Thanks.

SysCapstoneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

QPRCommented:
Try

<script language="Javascript">
<%=session("count")%>
</script>
0
bsdotnetCommented:
   <script language=vbscript>
        document.write(<%=session("count")%>)
    </script>

or

    <script language=javascript>
        document.write(<%=session("count")%>);
    </script>

or
    <%=session("count") %>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
QPRCommented:
OOps yes, BSDOTNET is correct - I forgot the document.write bit
0
RejojohnyCommented:
>>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>")
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.