Reputation: 11807
I have a page with (EnableViewState = "true") that has a parent control with (EnableViewState = "true"). The parent control loads a child control.
In the child control, I have a viewstate object that gets assigned to null on postbacks. The strange thing is if I set EnableViewState = "true" on the child control, then everything works fine.
My understanding was this directive is true by default. How does it matter whether I set this explicitly or not.
Upvotes: 1
Views: 1360
Reputation: 2897
If you use LoadControl() to load the controls, asp.net don't know how to restore those controls on postback. If you however make sure all controls are loaded in Page_Init, then the view state will be loaded into the controls.
This control does some of these things for you
Upvotes: 3