Last post Aug 10, 2011 05:10 PM by reza141414
Aug 05, 2011 06:51 AM|madhurbhardwaj|LINK
I am working on a web application. the problem i am facing is that the viewstate of my user control is lost on first post back.
I am loading Usercontrols in page load event. I've to load them in Page_load event because the value(user input) provided by user (which i am using to load usercontrols ) is a server control which is again loaded at run time (Dynamically) .. So i can't access
the actual value of this server control at Page_init event because the loadviewstate is called after Page_Init so i am not able to get user supplied value to dynamically load usercontrols.
Can any one help me ?
Aug 05, 2011 06:58 AM|subhash.sheladia|LINK
once postback occure dynamic generate code lost the data hence in user control you can not access that value. you have to again generate that dynamic value and passed into usercontrols method to access that values.
Aug 05, 2011 07:11 AM|madhurbhardwaj|LINK
Thanks for quick response.
I am not trying to access any value in user control . let me try to clear the question.
There is one main page on which I have a design time control let say (drop downlist) , now when user select any value from dropdown . it post back and i create a server control dynamically (lets say A textBox) . now user will put some value in text box which
I use to load user controls dynamically. The method which is used to create usercontrol can not be place in Page_init event because the view state of TextBox which i've created dynamicaaly is not available at Page_Init event . As you know the load view state
event is fired after Page_init.
Hope this will clear the problem ?
Aug 10, 2011 11:48 AM|madhurbhardwaj|LINK
Any one can help me ?
Aug 10, 2011 05:10 PM|reza141414|LINK
u should use some thing like ViewState or session...
u can use below for each control in ur userControl...
public Reserve ObjReserve
object o = ViewState["objReserve"];
return (o == null) ? objReserve : (Reserve)ViewState["objReserve"];
ViewState["objReserve"] = value;
objReserve = value;
Reserve is name of my class... u can use button or other control....it will solve ur problem
dont forget to mark as answer...