Need help persisting a dynamically loaded userControl...

U

Urbal

Ok, I've done quite a bit of testing and am stuck. Here's the
situation, I have two userControls and my webForm page.

menu.ascx - menu
contentEditor.ascx - input box + button
desktopDefault.aspx - blank, except menu.ascx userControl loaded


menu.ascx - obviously contains my menu, a selection of choices... when
the user clicks the "content editor" menu option, I load
contentEditor.ascx dynamically on desktopDefault.aspx by accessing the
<form> on the page and loading my control.

Now loading works just fine, but when I try to run my button_event from
contentEditor.ascx, it never fires. So far I have noticed that when I
click my "save" button on contentEditor.ascx, it does a few things:
--> Reloads DesktopDefault.aspx
--> Reloads menu.ascx

Now when it reloads menu.ascx, I lose the dynamically built control
contentEditor.ascx, which is why the button event never fires. My
question is, how do I maintain the contentEditor control on
desktopDefault.aspx and tell menu.ascx to again load my pre-selected
choice?

Any help is greatly appreciated. Thanks in advance.

-e
 
B

Brock Allen

When you dynamically add controls into the page it is up to you to recreate
them upon postback. The two places to do this is in Page_Init or CreateChildControls.
If you're doing this from a user control you can also do this from Page_Load.

The challenge is storing the necessary state information to remember what
controls to add.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top