Maintain value across postbacks ?
-
I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.
Use ViewState...
-
I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.
there is a State Management by viewstate . it's keep the value in the object so when ever we want to get value from viewstate we have to do boxing. a example for that suppose you want to save a textbox value //this is use to save the date ViewState["name"]=textbox.text; //this is use to retrive the date; textbox.text=ViewState["name"].ToString(); another is session //this is use to save the date session["name"]=textbox.text; //this is use to retrive the date; textbox.text=session["name"].ToString(); I Think this will be helpfull to you. bye take care. -- modified at 9:14 Tuesday 10th April, 2007
rajeev kumar sharma vri software pvt. ltd. new delhi India
-
I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.
-
Use ViewState...
-
Sorry - my question was more about whether a label is the correct control/method of persisting the value.
How will u maintain the different values??If u want only one value then u can use label...
-
I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.
-
I need to store a value on a page (and hide it from the user) and maintain it even when the page is posted back. I know I can do this by using a label (and setting it to visible = false). But is the best way of doing it ? Thanks.
Use ViewState, e.g.
ViewState("something") = something;
This is 'encrypted' and hidden from the user on the page.