Passing values from 1 page to another without using query string

  • Thread starter Thread starter Andy B.
  • Start date Start date
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.
 
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(
 
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
 
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.
 
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.
 
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()
 
Back
Top