Solved

How do you set Global variables in classic ASP pages?

Posted on 2011-03-08
3
402 Views
Last Modified: 2012-05-11
I need to set variables in an ASP app that are set to static values. So that when the app switches between pages via POSTs and GETs etc. it can still call them. How do I do this
0
Comment
Question by:Lico_w
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35069737
You would have to use either the Session (user scoped) or Application (application scoped) variables:
<%
     Application("SomeGlobalValue") = "someValue"        '// scoped to the application
     Session("SomeUserValue") = "someValue"               '// scoped to the current user
%>

Open in new window

0
 

Author Comment

by:Lico_w
ID: 35069831
What about if its an array or number?

Also how would you then call it in the code?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35069855
You can store arrays and numbers in there too. ASP is implicitly typed so as long as you know what type of data you are storing you're good to go.

To pull data back out is as simple as:
someGlobalValue = Application("SomeGlobalValue")
someUserValue = Session("SomeUserValue")

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

856 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