J
John
Hi all,
I am using dynamic user controls within my web app and these controls are
loaded into placeholders via the LoadControl method.
My problem is this:
I have usercontrolA loaded into a placholder and the user clicks on a
specific control outside of the usercontrol and some Javascript is run where
a hidden variable is changed to reflect another usercontrol (usercontrolB).
My main page fires upon postback and then checks the request variable (i.e.
hidden control) and then uses that variable to reload usercontrolB into the
placeholder upon which the app raises an exception :
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.
At this point, I know I don't want to use any of the viewstate that has been
stored.
My question is this:
What do I have to do to prevent this problem from occurring?
Can't I somehow clear the viewstate prior to loading usercontrolB?
Regards
John.
I am using dynamic user controls within my web app and these controls are
loaded into placeholders via the LoadControl method.
My problem is this:
I have usercontrolA loaded into a placholder and the user clicks on a
specific control outside of the usercontrol and some Javascript is run where
a hidden variable is changed to reflect another usercontrol (usercontrolB).
My main page fires upon postback and then checks the request variable (i.e.
hidden control) and then uses that variable to reload usercontrolB into the
placeholder upon which the app raises an exception :
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.
At this point, I know I don't want to use any of the viewstate that has been
stored.
My question is this:
What do I have to do to prevent this problem from occurring?
Can't I somehow clear the viewstate prior to loading usercontrolB?
Regards
John.