Posting Value to another form

B

Brian Shannon

Lets say I have web1.aspx which the user inputs data into txtData (text
box). When the user clicks the button ADD the browser takes the user to
web2.aspx. On web2.aspx I need to post the data entered from the first
page.

Is it best to use a querystring, session variable or is there a better
alternative. Currently I use session variables for a lot of my work but
want to get away from that since there are better alternatives.

Thanks
 
C

Curt_C [MVP]

QS will work fine if it's not a ton. Just have the button grab the value,
write it and then redirect.
 
S

S. Justin Gengo

Brian,

You could use server.transfer (That's my preferred method). Via
server.transfer there are two ways to send one form's data to another form.

The first is to use: Server.Transfer("webform2.aspx", True) where "True"
indicates that the previous forms querystring and post data should be
persisted and can then be accessed the same way as on webform1.aspx.

The second is to set any data you wish to transfer in the page's context
object which works the same way as many dictionary based objects:
Context.Items.Add("MyData", "This is a string")
Server.Transfer("webform2.aspx") and then on webform2.aspx retrieve the
data: Dim MyString As String = Context.Items.Item("MyData").ToString

Both methods may also be used together.

--
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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top