?
Solved

How To pass ASP parameter from 1 page to another

Posted on 2002-04-25
5
Medium Priority
?
271 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:gerry99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Accepted Solution

by:
xbathala earned 300 total points
ID: 6970104
yes you could pass it on to .asp pages as a form object or a querystring infinitely.

mypage.asp
<%strName = Request.Form("name")%>
<form action='mypage2.asp'>
<input type='hidden' name='name' value='<%=strName%>'>
<input type=submit>
</form>

and so on and so on...
in this example i assume that there was already a page before mypage.asp that has a form field called 'name'

but the best and easiest thing to use are session variables;
session("myName") = Request.Form("name")
you only assign call this once and you can use that variable in any page on your current session.

0
 
LVL 10

Expert Comment

by:slamhound
ID: 6970109
Your best bet is to store the value(s) in session variables. That way, they will be available to any page within that session. Something like:

<% 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("name")%>">
</form>

(be careful using "name" as a variable as it's probably a reserved word somewhere along the line.)

Slamhound

0
 

Expert Comment

by:ghadley
ID: 6970346
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("input1")
%>
</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
0
 
LVL 1

Author Comment

by:gerry99
ID: 6972035
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,
0
 
LVL 1

Author Comment

by:gerry99
ID: 6972047
Session variables do work.  It's too bad I need cookies for this, but we'll work with that.

Thanks,
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

777 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