Click to See Complete Forum and Search --> : Pass data from webform1 to webform2


Dozo_1st
September 9th, 2004, 07:40 AM
I have a class Customer which is declared on webform1 as
Public Shared MyCustomer As New CustomerThis object I want to pass from webform1 to webform2. How do I do this AND do this for every seperate user which uses these webforms?

When I use Public Shared, user2 gets the data stored by user1. How do I prevent this and have them both using their own separate Customer object?

I couldn't find this at the MS website. Does anyone have an ID?
Thanks for your help.

Dozo

Andrei_0
September 19th, 2004, 06:57 AM
I don't know if this is the best way to do it, but you can use the Session object to pass all kind of parameters between pages. (this is C# code, but the idea is the same in VB.NET)

In page 1 you do something like:

myCustomer=new Customer(); //doesn't have to be public
Session["customer"]=myCustomer;

and in page 2 you do:

Customer cust=((Customer)Session["customer"]);

if it doesn't work, try making the Customer class serializable

Andy Tacker
September 20th, 2004, 02:37 AM
In page 1 you do something like:
public void OnDone(...,...)
{
this.Session["customer"]="Mr.X";
}

and in page 2 you do:

private void showname()
{
label1.text = this.Session["customer"].ToString();
}

ABudair
September 20th, 2004, 09:21 AM
Dear,

Hi, i advise u to visit this link

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskretainingwebformspagevalueswithviewstateproperty.asp

Good Luck.

regards.
;)