471,873 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

Set Session Variable and Redirect

I have a list of items drawn from a SQL DB and listed on an ASP page. This
works fine.

How can I make it so that when a user clicks a particular item, a session
variable is set to the ID of the item and the user redirected to another
page?

Thanks
Jul 19 '05 #1
7 4663
link to the page you're on, with the id in the querystring. at the top
of the page, check for the querystring id, if <> "" then set the session
var and response.redirect to the next page.

for a bit more security, you could create a hidden form pointing to the
page you're on, set to post (so the id won't be in the querystring), and
have the link be javascript that changes the value of the id field to
that item's id and submits the form.

"Keith" <@.> wrote in message
news:#d**************@TK2MSFTNGP09.phx.gbl...
I have a list of items drawn from a SQL DB and listed on an ASP page. This works fine.

How can I make it so that when a user clicks a particular item, a session variable is set to the ID of the item and the user redirected to another page?

Jul 19 '05 #2
are you trying to do this clientside or serverside?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Keith" <@.> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I have a list of items drawn from a SQL DB and listed on an ASP page. This works fine.

How can I make it so that when a user clicks a particular item, a session
variable is set to the ID of the item and the user redirected to another
page?

Thanks

Jul 19 '05 #3
Would prefer server side but client side would work too

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
are you trying to do this clientside or serverside?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Keith" <@.> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I have a list of items drawn from a SQL DB and listed on an ASP page.

This
works fine.

How can I make it so that when a user clicks a particular item, a session variable is set to the ID of the item and the user redirected to another
page?

Thanks


Jul 19 '05 #4
just catch the POST and take the textbox value and put it in a Session
variable as you normally would, then redirect.

Session("MyVal") = Request.Form("textbox1")
Response.Redirect("yourpage.asp")

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Keith" <@.> wrote in message news:eT**************@tk2msftngp13.phx.gbl...
Would prefer server side but client side would work too

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
are you trying to do this clientside or serverside?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Keith" <@.> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I have a list of items drawn from a SQL DB and listed on an ASP page.

This
works fine.

How can I make it so that when a user clicks a particular item, a session variable is set to the ID of the item and the user redirected to another page?

Thanks



Jul 19 '05 #5
Thanks

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:er****************@TK2MSFTNGP11.phx.gbl...
just catch the POST and take the textbox value and put it in a Session
variable as you normally would, then redirect.

Session("MyVal") = Request.Form("textbox1")
Response.Redirect("yourpage.asp")

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Keith" <@.> wrote in message

news:eT**************@tk2msftngp13.phx.gbl...
Would prefer server side but client side would work too

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
are you trying to do this clientside or serverside?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Keith" <@.> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
> I have a list of items drawn from a SQL DB and listed on an ASP page. This
> works fine.
>
> How can I make it so that when a user clicks a particular item, a

session
> variable is set to the ID of the item and the user redirected to another > page?
>
> Thanks
>
>



Jul 19 '05 #6
http://www.gatewayorlando.com/conten...yRateSheet.asp

Features a list of destinations which when clicked will load a several
session variables and then redirect to a reservation request form. This
particular example uses a JavaScript function tied to the onClick event
for each TR.

onClick="trOnClick('38','20');"

function trOnClick(orgKey, destKey)
{
document.frmResortRateSheet.dropOffLocation.value = _
document.getElementById('destText' + destKey).innerHTML;

document.frmResortRateSheet.action = _
'../processingScripts/reservationRequestV3_loadTransfer.asp?org=' +
orgKey + '&dest=' + destKey;

document.frmResortRateSheet.submit();
}

The example above involves a form and changing the form's action before
submitting the form using code. An alternative would be to simply call
the page directly.

function trOnClick(destKey)
{
window.location.href='../processingScripts/rateQuoteSearch_setLocation.asp?location='
+ destKey
}

You could of course just set the onClick event to "window.location.href...".

David H
www.gatewayorlando.com

Keith wrote:
I have a list of items drawn from a SQL DB and listed on an ASP page. This
works fine.

How can I make it so that when a user clicks a particular item, a session
variable is set to the ID of the item and the user redirected to another
page?

Thanks


Jul 19 '05 #7
The ASP page called in my examples looks something like this

<% session("variableName") = "hello world"
response.redirect ("../content/reservationRequestV3_submit.asp")%>

Keith wrote:
I have a list of items drawn from a SQL DB and listed on an ASP page. This
works fine.

How can I make it so that when a user clicks a particular item, a session
variable is set to the ID of the item and the user redirected to another
page?

Thanks


Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Keith | last post: by
1 post views Thread by Scott Wickham | last post: by
1 post views Thread by farooqazeem | last post: by
9 posts views Thread by Greg Linwood | last post: by
6 posts views Thread by Mike | last post: by
7 posts views Thread by Lucas Tam | last post: by
6 posts views Thread by JJ_377 | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.