• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

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.

0
SysCapstone
Asked:
SysCapstone
  • 2
2 Solutions
 
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
 
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now