InterviewSolution
| 1. |
What is Control State? |
|
Answer» ASP.NET page has by default EnableViewState property true. This makes ASP.NET consequently monitor the CONDITION of the considerable number of controls present on the page. Presently on the off chance that I am dealing with a web page where I realize every one of the controls will be dynamically bound to certain information on each postback, I don't need to monitor the old data for the controls. So I may choose to turn it off. Presently this is a decent decision however things could get chaotic if a similar page contains a custom control and that custom control is utilizing ViewState to deal with the information inside the control. So, ASP.NET already PROVIDES a technique to handle such scenarios and it's called ControlState. At whatever point we build up a custom control and need to safeguard some data, we can utilize view state yet assume view state is DISABLED explicitly by the client, the control won't WORK as expected. For expected outcomes for the control we need to utilize Control State property. The Control state is isolated from the View state. The most effective method to utilize control state property, override the ONINIT() function for the control and include a call for the Page.RegisterRequiresControlState() function with the instance of the control to register. At that point override LoadControlState and SaveControlState so as to save the required state data. |
|