Data from one ASP page to another

G

Guy Hocking

Hi there,

First of all my apologies for seeming nieve and perhaps ignorant, i am new
to ASP so forgive me.

The Problem -
I have an ASP page that has a number of list boxes in a form. These list
boxes are populated; some by SQL tables and some just normal values.
Upon clicking the submit button the form runs a load of IF statements to
detirmine the correct page to be redirected to (response.redirect),
depending on what is in the list boxes.

The problem i have is that once the user has been redirected to the relevant
page, i cannot seem to display any data from the previous page.
I need, for example, to display the contents of ListBox1 on the second ASP
page.
What code do i need to do this? as i cannot get request.form or
response.write to work at all. Do i need to open a db connection again? or
somehow open a session?

NOTE that the form action = "", and it uses POST (so it posts to itself and
then redirects after the IF statements) not sure if thats a prob?

Thanks so much in advance

Guy

--
Guy Hocking
MCSE

www.bradflack.com

Please remove ANTI and SPAM from my
email address before sending me an email.
 
J

Jeff Cochran

First of all my apologies for seeming nieve and perhaps ignorant, i am new
to ASP so forgive me.

New isn't a problem. We were all new at one time.
The Problem -
I have an ASP page that has a number of list boxes in a form. These list
boxes are populated; some by SQL tables and some just normal values.
Upon clicking the submit button the form runs a load of IF statements to
detirmine the correct page to be redirected to (response.redirect),
depending on what is in the list boxes.

In IIS5/6 you might look at a Server.Transfer instead of a redirect.
The problem i have is that once the user has been redirected to the relevant
page, i cannot seem to display any data from the previous page.
I need, for example, to display the contents of ListBox1 on the second ASP
page.
What code do i need to do this? as i cannot get request.form or
response.write to work at all. Do i need to open a db connection again? or
somehow open a session?

The problem is the redirect. See:

http://www.aspfaq.com/show.asp?id=2217 (At the bottom)
NOTE that the form action = "", and it uses POST (so it posts to itself and
then redirects after the IF statements) not sure if thats a prob?

A GET would pass through, or you can fake it. See the URL above. Or
you could use session variables as an option.

Jeff
 
R

Roland Hall

:
: The Problem -
: I have an ASP page that has a number of list boxes in a form. These list
: boxes are populated; some by SQL tables and some just normal values.
: Upon clicking the submit button the form runs a load of IF statements to
: detirmine the correct page to be redirected to (response.redirect),
: depending on what is in the list boxes.
:
: The problem i have is that once the user has been redirected to the
relevant
: page, i cannot seem to display any data from the previous page.
: I need, for example, to display the contents of ListBox1 on the second ASP
: page.
: What code do i need to do this? as i cannot get request.form or
: response.write to work at all. Do i need to open a db connection again? or
: somehow open a session?
:
: NOTE that the form action = "", and it uses POST (so it posts to itself
and
: then redirects after the IF statements) not sure if thats a prob?

You should use something similar to:


<form id=form1 name=form1 method=POST onSubmit="return validate()">
....
</form>

In your validate routine...

<script type="text/javascript">
function validate() {
if... {
...
...
return false;
} else {
document.form1.action="processform.asp";
document.form1.submit();
return true;
}
}

You could also use the validate routine as generic and pass the form id if
you have more than one...
<form id=form1 name=form1 method=POST onSubmit="return validate(this.id)">


In processform.asp...

dim listVal
listVal = Request.Form("listval")

listval is whatever you want to call your list name in your form.

HTH...

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0
-Technet Script Center-
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
-MSDN Library-
http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top