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

Accessing form data from previous previous pages. 1

Status
Not open for further replies.

xenomage

Programmer
Jun 27, 2001
98
0
0
SG
Hi,

i am very new to asp, thought you guys can help me out here.
Been doing a few pages which requires a lot of data to to passed on to the finally page.

i know that i can keep using the ? operator to pass but the ending action statement would be really long. any way to solve this??
 
You can use the POST method to send data from one form to another in a hidden state. Unfortunately this data is lost once you move on to another page after the page submitted to. You could get around this in a number of ways, most easily either by using hidden fields in your form or session variables.

Hidden fields are just like normal fields but they do not get rendered by the browser. This means you can set their value to anything you like and then Request.Form them in the next page like a normal field.

Session variables are created like Session("VarName") = Value and then can be manipulated just like normal variables. They stay active as long as the session is active (20mins normally or until browser is closed) and can be referenced from any page after they have been created. The downside is that the client must have cookies enabled on their browser.

Hope this Helps

G -GTM Solutions, Home of USITE-
-=
 
thanks alot, but i don't quite understand about the session part.

does it mean that i can declare anything like :

Session("myVar") = 1

and then extract out the value two/three pages down?? if so, how can i free the variable?? and how do i define the session lenght??

Thanks.
 
Yes, you can use

Session("myvar") = some value

and you can get the value of Session("myvar") from any page as long as the session is active. By default it is active 20 minutes, but you can use:

Session.Timeout = n

to modify this default, where n is in minutes.

I generally prefer using hidden fields whenever possible because for using session variables the browser must have cookies enabled.
 
i can't use hidden field as the fields would disappear once i move on to another page.

so how do i tell the system that the session has ended before it "timeout"??
 
Thanks. One last qn.

What i am doing is a order form hence the need for so many var across pages. However, when the user post a order request, he/she must still be in session and i still need some of the session var.

so how do i effectivity remove the unwanted session variables??

session("myVar") = ""

OR

session("myVar") = NULL

is better??
 
Session.Abandon will distroy all the objects in Session and consiqently remove all variables and free up all resources. However if you want to remove a single variable, I think that Session("myVAr") = "" OR Session("MyVar")=NULL will work. ALthough I can't guarentee that this will free up resources.


Hope this Helps

G -GTM Solutions, Home of USITE-
-=
 
I think you can set session("var") = nothing to free up those resources --
penny.gif
penny.gif
 
Try using Session.Contents.Remove (implemented in ASP 3.0)
to remove the old data.

eg:
Session("myid") = 1

...

Session.Contents.Remove("myid")

Session.Contents.Remove takes either a name (signifying the name in the collection to be removed) or an integer (signifying the position in the collection to be removed)

hope this helps
leo
 
Hey,
I fairly new to ASP and InterDev and I was wondering how you can access the Session variable from another page. I am using
Code:
<%Session(&quot;clHoldate&quot;) = Date
mcaltext.value = Date%>
CentCal is my Calendar Control
Code:
<SCRIPT LANGUAGE=javascript FOR=CentCal EVENT=Click>
<!--
var index
index = 0
mcaltext.value = (CentCal.Value)
index = 1
CentCal_Click(mcaltext, index)

--->
</SCRIPT>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function CentCal_Click(mcaltext) {
clHoldate = mcaltext.value
window.open(&quot;//servername/Webfolder/myaspthatIamcalling.asp?clHoldate=&quot; + clHoldate)
}
//-->
</SCRIPT>
the new window pops up and I can see the correct data on the address bar, but how can I use clHoldate say to set a parameter in a DTC Recordset to display data in a DTC Grid.

Thanks for any help you can give!

tmishue
 
Thanks alot guys....it's been real helpful....many thanks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top