Passing Multiple objects from page to page
-
Problems are: 1. if i want to send multiple objects like one string and one int, how can i do it? 2. Let there is a class: class MyClass{ String id, name, address; MyClass(){...} } If i want to send a MyClass type object from one page to another what should i do now?
-
Problems are: 1. if i want to send multiple objects like one string and one int, how can i do it? 2. Let there is a class: class MyClass{ String id, name, address; MyClass(){...} } If i want to send a MyClass type object from one page to another what should i do now?
Zami_2 wrote:
1. if i want to send multiple objects like one string and one int, how can i do it?
strString = "myValue";
iInt = 10;
Response.Redirect("myurl.aspx?stringIWishToPass=" + strString + "&intIWishToPass=" + iInt.ToString());on myurl.aspx you can get this data like:
string strString = Request.QueryString["stringIWishToPass"];
int iInt = Convert.ToInt32(Request.QueryString["intIWishToPass"]);Zami_2 wrote:
2. Let there is a class: class MyClass{ String id, name, address; MyClass(){...} } If i want to send a MyClass type object from one page to another what should i do now?
MyClass myVar = new MyClass();
myVar.Name = "name";
...
Session.Add["something", myVar];
Response.Redirect("myurl.aspx");on myurl.aspx you can get the data as following:
MyClass myVar = (MyClass)Session["something"];
Greetings, KrIstOfK