Share data between pages

D

David Sagenaut

If I have two pages, page1 and page2. In page1, I have a label control.
After first request for page1, the label control fills with a text, say
"myName", then I pup up the page2. How can I get the label.text of page1
in page2? That is, I want to get data of controls in page1 to page2.
Thanks in advance.

David
 
S

S. Justin Gengo

David,

There are a number of ways to do this, but I have a question about the way
you worded your question: What do you mean by pup up (I assume you meant to
type pop up) page 2. Do you mean that the user is pulling up a second window
entirely and you want to send data to it, or do you mean that page 1 is
going to turn into page 2? The way to get information to page 2 is going to
differ based on that clarification.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

If need to store only few values, Session is the fastest & easiest method.

If you are talking abt a large transaction that spans across pages, one
solution is to

1) Design a table to hold all the transaction data..
2) At first page create an entry in the table for userid
3) Store the control values in this table from each page before transfering
to next page
4) In each page read the values from table and populate the controls
5) Upon final submit, delete the values [Or periodically delete using a
scheduled job, if the transaction data would help for debugging the app]
 
D

David Sagenaut

Thanks, Justin. The scenario in my mind is that there is link in page1.
After you click the link, the page2 opens. I want to show the text of the
label in page1 on the page2.

David
 
S

S. Justin Gengo

David,

There are two different ways to do this then (really there are more, but I
would only consider these three because other methods are overly complex).

One way would be to simply store the text in a session variable and call it
from the second page:

page 1:
Session("MyText") = "Text goes here"

page 2:
Dim MyText As String = Session("MyText").ToString


Another way would be to use Server.Transfer combined with storing the text
in the Context object:

page 1:
Context.Items.Add("MyText", "Text goes here")
Server.Transfer("Page2.aspx")

page 2:
Dim MyText As String = Context.Items.Item("MyText").ToString

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top