Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Transferring data from one webform to another webform ASP.NET

Hi Guys,

I have a webform called wb1.aspx in that i have 2 fields called "name" and "phone number". I want to pass this Data of Name and Phone number to another webform called wb2.aspx, where i have the same fields in wb2.aspx. can you guys help me with code.? I am using VB.NET as a language.
Thanks,
[318 byte] By [saidev] at [2007-11-11 7:36:34]
# 1 Re: Transferring data from one webform to another webform ASP.NET
It depends on whether you are passing your values via the querystring collection or the form collection. In either case, you need to use the Request object to retrieve the values. If you are navigating to wb2.aspx via querystring, then you should see something similar to this in the address bar: http://localhost/wb2.aspx?name=whatever&phone=111-222-3333

If that is the case, then you can fill your new form's controls with:
name.Text = Request.Querystring("name")
phone.Text = Request.Querystring("phone")

If you are passing the values via the form collection, you just replace 'Querystring' with 'Form', like so:

name.Text = Request.Form("name")
phone.Text = Request.Form("phone")

Hope this helps.

Edit: if your second field is really called 'phone number', you should change it to something without spaces. Using spaces in identifiers will always cause you grief at some point, just a suggestion.
piratepops at 2007-11-11 23:13:40 >