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

passing info from a page with recordsets

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
0
0
US
I have several pages with forms that need to be asp pages because I get info for the form from listbox dtcs or from vbscript.
I just found out that you can't have a form on such a page as I discovered because the page kept submitting to itself.
How do I pass the info from the form from one page to the next?
I thought of adding it to an <href=&quot;page.asp?name=txtbox&name=textbox&quot;> etc. but sometimes it's a whole form, and also I'm not sure of the syntax.

Any help would be appreciated. Thanks.
 
If you are calling an ASP from a form, then you can get the data from the form by using:

field = request.form(&quot;fieldname&quot;)

HTH

Mike
 
If you are passing the information in the url then use

Request.QueryString() but I would suggest using what MNClimber said, Request.Form(&quot;fieldName&quot;)

Also, it's possible to submit a form to the page the form is located on. I would use a hidden textbox (value=0) to hold a value, when you submit to the same page change the value in the hidden textbox from 0 to 1. This way you know the page was submitted.

Another possible way is to use layers.

These are not your only choices but just a few off the top of my head.
 
Thanks, but I think you misunderstood my problem.
The page won't submit! It's going to itself, and that's not what I want. Something about a DTC is its own html and submits its own form so you can't send info from .asp to .asp with a form.

Any other ideas?
 
Do you have the &quot;action&quot; property in the <FORM> tag set to go to the desired page??

And you're right...I don't understand your problem, my last response was kind of a guess as to what you are trying to get at...sorry.

Mike
 
The Script Object Model, that you need if you use DTC's, always adds a form wrapper around the whole page. You can see it in grey at the top and bottom of the page code, and you cannot edit it. It submits back to itself so that validation etc. can occur, and so that your code knows all about the objectes that it is dealing with.

There are alternatives.
Firstly, do not use the SOM or DTC's for your forms - however, this may seem a bit alarming!

Another idea is to use the PageObject DTC. Once added to all pages, you can set a reference from one page to another on the third tab of the page object. Now add a server-side function to each form, that takes the required form values as a parameter(s). Include this function in the PageObject as a 'navigate' function. Now you can route from one page to another, passing parameters (even from client side code). If you figure this out, you will see that it just builds up a redirect command with a load of query-string values - but its easy and effective.

A third idea is to stuff all required values into the session object. Remember to clear this as soon as posible.

And finally, you could store the values of each page into a database - which is the likely target for the info anyway.

What you, and I, really want is a Form-Redirect - to redirect a complete form to another page on the server. I think that IIS 5 supports such a notion, but I am not sure. (Content Management)
 
This PageObject looks like the answer to many problems.
Thanks.

Now, how do I use it?

For example, I have a page that takes the values from an html form and if they are empty, brings back the &quot;label&quot; of the textbox red, etc.

I put a PageObject on the html page and on the validation.asp page and made the contents of the validation.asp page a navigate method of the pageObject and passed it the values from the querystring of the html page.(Is this necessary?)
Nothing shows up on the validation.asp page. The values are getting passed OK, I see them in the URL.

I guess what I need is a comprhensive help on how to use the PageObject for my needs.

I tried the MSDN help but it was too basic and not specific enough.

Do you have any ideas or help for me?

Thank you.
 
Using the SOM model, the form (text boxes etc.) and the validation code are in the same .ASP page - it loops around until everything is OK. If you then need to pass this data on to another form then you need to (pick one!):
* Store the data in a database
* Store the data in a cookie
* Store the data in a session variable
* Pass the data on to the next form via the query string

The first three methods have their own good and bad points. The last two methods are made easier when using the 'PageObject'.

* Session Variables
Without the page object you would need to store values to the session object manually:
Session(&quot;MyVar&quot;) = &quot;Fred&quot;
No problem, until you are editing another page - can you remember the name of the session variable? (MyVar) Well use the PageObject, and you can see the names of session values on the referenced pages. It also prevents the same session variable name being used for two different purposes [it adds the pageobject name infront of each variable name].

* Query String
Without the page object, you would need to construct a URL including all of the form values gathered so far:
Page2.asp?Var1=Fred&Var2=Bloggs& ...etc...
You could semi-automate this, by looping through the Form collection, construncting the Name=Value pairs as required.
Once done, you redirect to this url.
Or you could use a PageObject navigate method - where each value that you want to pass is listed as a parameter to the method. This simply then constructs the URL query string for you, does the redirect, and ensures that method on the target page is called with the parameters.
- Not sutable for forms with large values (URL's can only be about 1000 characters). Not to good for forms with many form fields. (Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top