Usercontrol dynamically loaded (in Init method of webcontrol) have viewstate problems

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top