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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables

Status
Not open for further replies.

JJBean1

IS-IT--Management
Sep 30, 2004
24
US
Hi,

What's the preferred way to pass variables around to different pages now? Or if my reading servers me right they are retained in memory for the life of the app, correct? How do I access these variables if in a different page than the one variable was created in?

Thanks,

JJ
 
session and query strings are the 2 main ways. query strings are less secure, but they are plain text and visible in the address bar. Session is more secure, but requires more server resources. you will also need to cast the value to the appropiate type when you request the value.

Session will also last from page to page once you set it. query strings need to be passed each time a new page is accessed.

to store a value in sesison is [tt]session("[variable name]") = [value to store][/tt]
a querystring is placed on the end of the url with the format [tt]mypage.asxp?[key1]=[value1]&[key2]=[value2][/tt]
where key is the variable name and value is the value to pass. it must start with a question mark. Seperate key/value pairs with the & symbol.

in your code behind on the next page use request.querystring([key]) to get the value of the key.

Jason Meckley
Database Analyst
WITF
 
a even better way is to use a database to store values.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top