Need help persisting a dynamically loaded userControl...

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Need help persisting a dynamically loaded userControl...

    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

    Urbal Guest

  2. Similar Questions and Discussions

    1. dynamically add usercontrol
      Hi Can anybody explain to me how to dynamically add a usercontrol? When I try to use the this.Controls.Add the control is added, but none of the...
    2. Dynamically loaded text file
      When a page is uploaded in Contribute 3, it also uploads dependent files attached to it: images, pdf's, etc. My question is, does it also upload...
    3. Dynamically added usercontrol raised events
      I've tried and tried and this problem eludes me. I have a form called "main" which has a div tag "DeptInfo" in which I add my control...
    4. UserControl not capturing Button click event when loaded with PlaceHolder Control
      My UI is one table, 2 colums, one row. The cell on the left has a tree and the cell on the right has a placeholder control. When the user clicks on...
    5. Event not firing. Adding controls dynamically to UserControl
      I am adding controls to the UserControl dynamically and then loading the UserControl Dynamically.But I am facing problem with firing of click event...
  3. #2

    Default Re: Need help persisting a dynamically loaded userControl...

    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.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > 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
    >


    Brock Allen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139