pass the values of variable in code Behind
-
Hi, we use PostBackUrl passing values of controls from one page to anther page in encrypted way(FORM) can i use same method to pass the values of variable in code Behind of page 1 to code Behind of page 2? any one explain thanks a lot....
In your second page, look at using
PreviousPage.FindControl()
passing it the control ID of the control you want the data from in the first page. You'll have to typecast it to the proper control type to get the data, but this does work. I don't believe that this encrypts the data, but it is not visible in the URL. -Matt------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall
-
In your second page, look at using
PreviousPage.FindControl()
passing it the control ID of the control you want the data from in the first page. You'll have to typecast it to the proper control type to get the data, but this does work. I don't believe that this encrypts the data, but it is not visible in the URL. -Matt------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall
-
This is good But I mean how I can pass the values of variable in code behind of page 1 to page 2 thanks
If all you want is to pass the value of a variable, just use your Session object:
/// Add variable to Session object in Page1
Session["variable_name"] = myVariable;And then in your second page
/// Retrieve the variable you added in Page1
string myVariable = Session["variable_name"].ToString();If this is not feasible because you don't want to use cookies (which Session uses by default), there is a way to enable cookieless sessions. -Matt
------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall