By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

transferring data to different page

P: n/a
hi guys I don't know if this is the right place for it but
I created 2 pages
in page one there is a text box in which the user enters his name,
in page 2 there is a the same text box.
I would like the data to be transferred automatically to the second page
how do I do that ?
thanks

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
yes, it's the right place..and how is the user getting from page one to page
2? is he or she clicking on a link or a button?

There are a couple ways, but none are automatic...you need to grab the data
on the postback to page 1 and redirect/transfer to page 2..

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("page2.aspx?value=" + textbox.Text);
}

or using Context.Items and Server.Transfer
and in page2 you get the value and populate the other textbox

Page_Load
TextBox.Text = Request.QueryString["value"];
end
the above is pretty crappy code (no error check and stuff), but not 100%
sure what mechanism you already have in place...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Rani" <ra***@hotmail.com> wrote in message
news:uZ**************@TK2MSFTNGP09.phx.gbl...
hi guys I don't know if this is the right place for it but
I created 2 pages
in page one there is a text box in which the user enters his name,
in page 2 there is a the same text box.
I would like the data to be transferred automatically to the second page
how do I do that ?
thanks

Nov 19 '05 #2

P: n/a
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rani" <ra***@hotmail.com> wrote in message
news:uZ**************@TK2MSFTNGP09.phx.gbl...
hi guys I don't know if this is the right place for it but
I created 2 pages
in page one there is a text box in which the user enters his name,
in page 2 there is a the same text box.
I would like the data to be transferred automatically to the second page
how do I do that ?
thanks

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.