|
-
May 4th, 2001, 01:39 PM
#1
Thread Starter
Lively Member
Read Variable from 2nd asp page
Hi all,
I have variable declared in my first asp page
<%
Dim userId
userId=Request.form("name")
I user this userId in my queries and it works fine
%>
Now I try to use the userId in my queries, in my second asp page, and it doesn't work. I also used <!--#include file="start.asp"--> in my second asp page.
Am I doing something wrong in here. Why can my second asp page recognize the variables I declared in my first asp page??
Reggie
-
May 4th, 2001, 01:57 PM
#2
Black Cat
Variables declared on a page only have scope for that page. You need to use something session variables or another form of persistance.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
May 4th, 2001, 11:23 PM
#3
Frenzied Member
You can pass it with a querystring, or if your using a form that is submitted to page 2, you can write the value of UserID into a hidden textfield that will be passed with the form to the next page, then just grab it out of the request.form collection.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
May 5th, 2001, 06:47 PM
#4
Good Ol' Platypus
Adding a form to EVERY SINGLE PAGE can be a bit, uh...
TEDIOUS.
So use session variables!!!
Code:
<%
Function OutSV(Varb)
Response.Write Session(Varb)
End Function
Function ReadSV(Varb)
ReadSessionVariable = Session(Varb)
End Function
Function SetSV(Varb, Val)
Session(Varb) = Val
End Function
%>
Usage:
Code:
<%
'global.asa
SetSV "Ab","BA"
'asp1.asp
OutSV "Ab" '<---WILL DISPLAY 'BA'
%>
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 5th, 2001, 07:28 PM
#5
Frenzied Member
Session variables are one solution, but it is at the price of scalabilty. It will work fine as long as the app never needs to grow beyond a single server. A querystring would be a solution that scales to multiple servers if needed.
I'm not arguing the value of the session object.. I use it on small scale apps that will only be used in an Intranet. But if your planning to do serious development in ASP, don't rely on it too heavily.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
May 7th, 2001, 09:05 AM
#6
Black Cat
Notice how I said "session variables or another form of persistance."
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|