gerry99
asked on
How To pass ASP parameter from 1 page to another
How do I pass a parameter from one ASP page to another?
I have some form variable that I can read in a page, that needs to pass them to another page. Do I repost them as form variable? How is that done?
mypage.asp
<%
' input values
strName = Request.Form("name")
%>
<html>
<head></head>
<body>
<p>paragraph
<p>paragraph
<img src="daily.asp">
</body>
</html>
Thanks,
Gerry
I have some form variable that I can read in a page, that needs to pass them to another page. Do I repost them as form variable? How is that done?
mypage.asp
<%
' input values
strName = Request.Form("name")
%>
<html>
<head></head>
<body>
<p>paragraph
<p>paragraph
<img src="daily.asp">
</body>
</html>
Thanks,
Gerry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As far as I know, using request.querystring is the best way to pass variables from one page to other if the data you want to pass does not have secure issue, such as credit card or ssn. try the following codes:
page1.asp
************************** ********** ********** *****
<form action=page2.asp method=get>
<input name=input1 value=1>
<input type=submit name=submit1 value=submit>
<%
'if input1 is empty then this text will be displayed.
response.write request.querystring("input 1")
%>
</form>
page2.asp
<%
input1=request.querystring ("input1")
if LEN(input1)=0 then
server.transfer "page1.asp"
else
response.write input1
end if
%>
************************** ********** ********** ******
It is not a good idea to use session variable because it does have limited time(default 20mins)
Ricky
page1.asp
**************************
<form action=page2.asp method=get>
<input name=input1 value=1>
<input type=submit name=submit1 value=submit>
<%
'if input1 is empty then this text will be displayed.
response.write request.querystring("input
%>
</form>
page2.asp
<%
input1=request.querystring
if LEN(input1)=0 then
server.transfer "page1.asp"
else
response.write input1
end if
%>
**************************
It is not a good idea to use session variable because it does have limited time(default 20mins)
Ricky
ASKER
I could transfer the parameters alright, but the page was returned to the client side without processing the asp that parameters were transfered to.
I don't know why. The session variable example does work, the timeout period is not a problem, the user requirement that cookies be enabled is a problem, but I think we can live with it.
Thanks,
I don't know why. The session variable example does work, the timeout period is not a problem, the user requirement that cookies be enabled is a problem, but I think we can live with it.
Thanks,
ASKER
Session variables do work. It's too bad I need cookies for this, but we'll work with that.
Thanks,
Thanks,
<% session("strName") = request.form("name") %>
to set it up and then just use it like any other variable on any other page. eg:
<%response.write session("strName")%>
My name is <%=session("strName")%>
The harder, uglier way is to set up hidden fields in forms like:
<form method=post action="myPage.asp">
<input type=hidden name="name" value="<%=request.form("na
</form>
(be careful using "name" as a variable as it's probably a reserved word somewhere along the line.)
Slamhound