We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

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

SysCapstone
SysCapstone asked
on
Medium Priority
459 Views
Last Modified: 2008-03-10

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.

Comment
Watch Question

QPR

Commented:
Try

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

or

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

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
QPR

Commented:
OOps yes, BSDOTNET is correct - I forgot the document.write bit
>>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>")
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.