locked
Dynamically Loaded Control Wants to Change The Dynamically Loaded Control RRS feed

  • Question

  • User1757172363 posted

    I have been playing around with dynamically loading controls and AJAX and have the following:

    An UpdatePanel has a PlaceHolder which which contains a dynamically loaded control.  The control that is dynamically loaded has a button that is supposed to change the control that was loaded.  So after the link button is clicked on DynamicControlA, DynamicControlB should now be loaded where DynamicControlA used to be.

     Is there anything in the framework to do this?  If not, any ideas on how to tackle?

    Monday, June 23, 2008 2:04 PM

Answers

  • User-16411453 posted

    I have no clue what your control looks like, or how it is designed. So I have no ideas.

    I've never made a user control, just server controls, so I not sure what your up against. The example below is a server controls that just switches panels.  It is self contained with all code and artwork compiled into the dll.

     This site is a test prototype site, not done yet.  Some bugs exist. The movies are a single control, with 2 panels, one vertical and one horizontal.

    http://testdrive.ice5software.com/Movies/index.aspx?cp=1&ni=3&os=6&s=NAME&d=s 


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2008 10:13 PM
  • User-1136466523 posted

    Hi,

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    I’m not sure what does the ControlHub look like? Is it a special control to act as a hub for your dynamic forms?

    <o:p> </o:p>

    You mentioned that you have involved Ajax in your application, right? In my points of view, I think the correct scenario is loading creating all of your controls at the first time instead of loading different controls each time. So using multiView to hold your user controls can be a practice. Besides, you can expose an event from each of your user control which links to different link buttons, and assign the event with a shared event handler that switches the ActiveViewIndex property of the multiview accordingly.

    <o:p> </o:p>

    Thanks.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 25, 2008 10:51 PM

All replies

  • User-16411453 posted

    I did it with Panels.  Made 5 panels all the same size, and toggled visible for the panel I needed to display. The panels contain the controls.

    Panels are just div tags.

    Monday, June 23, 2008 7:05 PM
  • User1757172363 posted

    That's one way to do it I guess.  It just doesn't sit right with me for some reason.  What I ended up doing is the following:

     

    Created a public method in my "ControlHub" (just a user control) that acts as a hub for the dynamic forms.  Then I just have to find the control hub in each sub form and ask it to switch screens.  I am sure there is a way to abstract "finding the control hub" but for some reason I get some crazy errors when I inherit from anything other than UserControl.  Something along the lines of "must inherit from UserControl or Page".  My class did inherit from UserControl, but I guess it didn't like it much.  Any ideas?

    Monday, June 23, 2008 9:27 PM
  • User-16411453 posted

    I have no clue what your control looks like, or how it is designed. So I have no ideas.

    I've never made a user control, just server controls, so I not sure what your up against. The example below is a server controls that just switches panels.  It is self contained with all code and artwork compiled into the dll.

     This site is a test prototype site, not done yet.  Some bugs exist. The movies are a single control, with 2 panels, one vertical and one horizontal.

    http://testdrive.ice5software.com/Movies/index.aspx?cp=1&ni=3&os=6&s=NAME&d=s 


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2008 10:13 PM
  • User-1136466523 posted

    Hi,

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    I’m not sure what does the ControlHub look like? Is it a special control to act as a hub for your dynamic forms?

    <o:p> </o:p>

    You mentioned that you have involved Ajax in your application, right? In my points of view, I think the correct scenario is loading creating all of your controls at the first time instead of loading different controls each time. So using multiView to hold your user controls can be a practice. Besides, you can expose an event from each of your user control which links to different link buttons, and assign the event with a shared event handler that switches the ActiveViewIndex property of the multiview accordingly.

    <o:p> </o:p>

    Thanks.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 25, 2008 10:51 PM
  • User1757172363 posted

     To close this post...

     I was a little suprised to see everyone arguing against dynamically loading user controls, but I fell in line and used a multiview and it works nicely.

    Friday, June 27, 2008 10:54 AM
  • User-16411453 posted

    I use to use the Multiview control, but stopped using it when I started writing server controls.  Can't remember why, but I think it was a design issue.  Use what feels most comfortable to you.

    Friday, June 27, 2008 1:24 PM