I have a few user controls which I add to the aspx form depending on the user's choice from a combo box. I have a user control which has a textbox in it and a getValue() method that returns the value of the textbox.
After user selects the related item I load the control and add to a panel using loadControl method. User enters some text. After a postback I want to keep the user control and the user input in the same state before .
Hope this is clear.
There is going to be a two step process.
The key here being that you MUST add the control in Init so that viewstate can be loaded.
You can add whatever you like to the page state using ViewState.
ViewState["myvalue"] = "?";
In this way you can inspect previous values on future postbacks like so:
someVariable = ViewState["myvalue"];
Even better, you can encapsulate this in a property on your page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.