M
Matt Howeson
I have a problem with a usercontrol that is dynamically loaded, from a web
control and is not restoring it's viewstate properly.
Here's the scenario. Within our content management system, I have a
webcontrol which allows a admin user to select a usercontrol to include
within a page when in "edit mode".
When a user is editing the page they see a dropdown list of available
controls and select one and save the page, kind of irrelevant to this
problem but it gives some background.
When the page is constructed to be served the webcontrol checks which
usercontrol has been selected in it's Init method and adds the
approprapriate usercontrol to the webcontrols' Controls collection.
When the usercontrol is loaded dynamically it loads a repeater on the page,
and it's contents should be stored in the viewstate. However when a
postback is carried out the contents of any controls within the dynamically
loaded usercontrol are lost.
Any help or advice on this greatly appreciated. Please note the controls
are loaded in the Init method of the webcontrol, so before the Loadviewstate
method fires, and at the loadviewstate and saveviewstate methods are both
being called for the dynamically loaded usercontrol.
Thanks,
Matt
control and is not restoring it's viewstate properly.
Here's the scenario. Within our content management system, I have a
webcontrol which allows a admin user to select a usercontrol to include
within a page when in "edit mode".
When a user is editing the page they see a dropdown list of available
controls and select one and save the page, kind of irrelevant to this
problem but it gives some background.
When the page is constructed to be served the webcontrol checks which
usercontrol has been selected in it's Init method and adds the
approprapriate usercontrol to the webcontrols' Controls collection.
When the usercontrol is loaded dynamically it loads a repeater on the page,
and it's contents should be stored in the viewstate. However when a
postback is carried out the contents of any controls within the dynamically
loaded usercontrol are lost.
Any help or advice on this greatly appreciated. Please note the controls
are loaded in the Init method of the webcontrol, so before the Loadviewstate
method fires, and at the loadviewstate and saveviewstate methods are both
being called for the dynamically loaded usercontrol.
Thanks,
Matt