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

Carry Over Field Values

Status
Not open for further replies.

tekyge

Programmer
Dec 11, 2005
125
US
Is there a way to carry over a field value from one page to the next with asp without using a form? Lets say i have a hidden field called ClientID and I want to carry over its value when I click a hyperlink going to the next page. Any one have a clue it would be grateful.
 
you can use a session variable...

session("myvar")=value

on the next page you can access session("myvar")

or put the value in the hyperlink using....


then on the next page you can retrieve using...

request.querystring("myvar")

-DNG
 
I use the following code to hide query string values. Its a simple way of protecting your data that is passed onto another page. This keeps folks from modifing your query string to gather unathorized data from your db.

First I create a onClick event.

<script language="JavaScript">
function SetVar(strVar)
{
document.cookie = "Var" + "=" + strVar + ";";
}
</script>



Then I stuff the querystring with a value.

<A HREF="somepage.asp?ID=<%= rs("dbValue")%>" onClick="SetVar(<%=rs("dbValue")%>)">Click here</A>


The second page contains the following code.

intVar=Request.Cookies("var")
'now lets clear the contents of the cookie
Response.Cookies("var").expires= Date() - 5
'now lets redirect the user if an attempt to was made to modify query string
If intVar = "" Then
response.redirect("SecurityIssue.asp")
End If
 
I can't get it to work. I have a hidden field that carries an ID number and I want to carry the value oif this field over to the next page. I also want it to be in vb because some clients my not have java enabled and I would rather it be server side. Thanks guys.
 
did u try the method i suggested...show us the relevant parts of your code..."I can't get it to work" does not help us to answer your question...also tell us what error you are getting...

-DNG
 
My problem is Im not clear where "session("myvar")=value" goes on the page. I had it like this on the first page <%session("myvar")=value %> and like this on the next page <%= request.querystring("myvar") %> ?
 
if you have
session("myvar")=somevalue
then on the second page just access it using
session("myvar")

for testing...you can do a response.write on page 2...

response.write session("myvar")

-DNG
 
Ok on first page I have:

<%session("ClientID")=value %>

Second Page:

<%= request.querystring("ClientID") %>

On first page all it shows is True
 
i am sorry to say but i would suggest you reading some basics at

all the code i was providing so far is just a pseudo code...you need to replace with your own values and variables...

show us your complete code...

-DNG
 
I did post the code, but I found another solution thanks.
 
Thanks dot For some reason the <%= session("ClientID") %> works now without anything on the first page it pulls the ID over to the hidden field like I wanted. What was confuseing me was it should work but was not responding. Thanks for your help
 
Just so I don't confuse anyone the code is like Dot said:

Page one:
session("myvar")=blah

Page Two:
Calles session value from page one.
session("myvar")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top