J
Jed
I am getting the old "Failed to load viewstate." error and I can't figure out
why.
ERROR:
"Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during the
previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request."
I am making a UserControl. It has two panels. Each panel represents an
alternate display mode. Both panels are wrapped in a primary panel.
The UserControl has a public DisplayMode property which determines which
panel to show. The point is that the mode will remain the same throughout
the "is or isn't postback" process. They are both declaratively set
Visible=False by default.
In the Init of the UserControl I hydrate the controls of the appropriate
panel and set it to visible. In other words this happens on postback too.
If I set the second panel on the UserControl to Visible the postback works,
however if I set the first panel to visible I get the ViewState error. I
have tried physically reversing them in design mode and the above holds true.
My controls are initialized before SaveViewState occurs. They are certainly
recreated by the same code on postback, so this error should not be occurring.
Obviously, if I set ViewState off it all works fine. I want ViewState on.
Why doesn't this work?
why.
ERROR:
"Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during the
previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request."
I am making a UserControl. It has two panels. Each panel represents an
alternate display mode. Both panels are wrapped in a primary panel.
The UserControl has a public DisplayMode property which determines which
panel to show. The point is that the mode will remain the same throughout
the "is or isn't postback" process. They are both declaratively set
Visible=False by default.
In the Init of the UserControl I hydrate the controls of the appropriate
panel and set it to visible. In other words this happens on postback too.
If I set the second panel on the UserControl to Visible the postback works,
however if I set the first panel to visible I get the ViewState error. I
have tried physically reversing them in design mode and the above holds true.
My controls are initialized before SaveViewState occurs. They are certainly
recreated by the same code on postback, so this error should not be occurring.
Obviously, if I set ViewState off it all works fine. I want ViewState on.
Why doesn't this work?