Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP variables

Status
Not open for further replies.

checkai

Programmer
Jan 17, 2003
1,629
0
0
US
I want to declare/initialize variables that I can use throughout the entire web page...

where do I put these statements...

for instance

clientID = the querystring and i use it in a few button click events but I only want to define it once...

DLC
 
Is it ASP or ASP.NET that you use? You may want to consider using Session variable as you can access it everywhere you want within the application and it lives as long as Browser is open and can only be accessed by user who has a current session.

session("ClientID") = 'your_query_string' ...and as you logout you can either reset the session variable: session("ClientID") = "" or kill it: session.abandon() - in this case all session variables will be cleared.

Kevin.
 
...well then you can add a VB Module into your project: something like 'common.vb' and declare your variable as "Friend" inside of it. It'll be seen everywhere within the project:

Module common
friend ClientID as String
End Module

In this case you need to remember that other users that come in to the application will be seeing this variable and even will be able to update it since the var lives on the server. That is why in my applications I am trying to use Session variables as they pertain only to 1 user that is loged on to application.

Kevin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top