467,139 Members | 1,348 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,139 developers. It's quick & easy.

transferring data to different page

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
  • viewed: 1343
Share:
2 Replies
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
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.

Similar topics

9 posts views Thread by Mark | last post: by
15 posts views Thread by http://www.visual-basic-data-mining.net/forum | last post: by
5 posts views Thread by meetalps | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.