Passing values from 1 page to another without using query string

A

Andy B.

I need to get values from a page and use them inside another. I don't
want to use the query string for this since it would be very long. How
would I do something like this? The page with the values to use would
have been the last one visited.
 
K

Karl Mitschke

Hello Andy B.,
I need to get values from a page and use them inside another. I don't
want to use the query string for this since it would be very long. How
would I do something like this? The page with the values to use would
have been the last one visited.

Look up "Session"

Use it like:
Session["AdminID"] = Request.ServerVariables["LOGON_USER"];

And then, later you can reference the login user by:

Session["AdminID"].ToString(
 
S

Steve S

You could also use Context.Items but you can only use this with
Server.Transfer.

Page 1
Me.Context.Items.Add("TestValue", 10)
Me.Server.Transfer("Page2.aspx")

Page 2.
Dim TestValue As Integer = Me.Context.Items.item("TestValue")

SteveS
 
A

Andy B.

Steve said:
You could also use Context.Items but you can only use this with
Server.Transfer.

Page 1
Me.Context.Items.Add("TestValue", 10)
Me.Server.Transfer("Page2.aspx")

Page 2.
Dim TestValue As Integer = Me.Context.Items.item("TestValue")

SteveS

Hi. I think I found a way to do it. I will define public properties on
the source page and then reference them on the target page. Seems to be
the easiest way to do what I need.
 
S

Steve S

sounds good.

Andy B. said:
Hi. I think I found a way to do it. I will define public properties on the
source page and then reference them on the target page. Seems to be the
easiest way to do what I need.
 
Y

Yankee Imperialist Dog

an alternative is to use cross page post back. There are issues with posting
back again to the calling page.

see: http://www.codeproject.com/KB/aspnet/CrossPagePostbackCirRef.aspx

this is a simple way to do it but it's useful if you have a lot of values
--
Share The Knowledge. I need all the help I can get and so do you!


Karl Mitschke said:
Hello Andy B.,
I need to get values from a page and use them inside another. I don't
want to use the query string for this since it would be very long. How
would I do something like this? The page with the values to use would
have been the last one visited.

Look up "Session"

Use it like:
Session["AdminID"] = Request.ServerVariables["LOGON_USER"];

And then, later you can reference the login user by:

Session["AdminID"].ToString()
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top