Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

Last post 06-27-2008 1:24 PM by jkirkerx. 6 replies.

Sort Posts:

  • Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

    06-23-2008, 2:04 PM
    • Member
      2 point Member
    • mkubaryc
    • Member since 06-23-2008, 5:58 PM
    • Posts 30

    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?

  • Re: Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

    06-23-2008, 7:05 PM
    • Participant
      1,882 point Participant
    • jkirkerx
    • Member since 12-07-2007, 2:52 AM
    • Huntington Beach CA
    • Posts 442

    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.

  • Re: Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

    06-23-2008, 9:27 PM
    • Member
      2 point Member
    • mkubaryc
    • Member since 06-23-2008, 5:58 PM
    • Posts 30

    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?

  • Re: Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

    06-23-2008, 10:13 PM
    Answer
    • Participant
      1,882 point Participant
    • jkirkerx
    • Member since 12-07-2007, 2:52 AM
    • Huntington Beach CA
    • Posts 442

    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 


  • Re: Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

    06-25-2008, 10:51 PM
    Answer

    Hi,

     

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

     

    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.

     

    Thanks.

     

    Michael Jin.
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

    06-27-2008, 10:54 AM
    • Member
      2 point Member
    • mkubaryc
    • Member since 06-23-2008, 5:58 PM
    • Posts 30

     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.

  • Re: Dynamically Loaded Control Wants to Change The Dynamically Loaded Control

    06-27-2008, 1:24 PM
    • Participant
      1,882 point Participant
    • jkirkerx
    • Member since 12-07-2007, 2:52 AM
    • Huntington Beach CA
    • Posts 442

    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.

Page 1 of 1 (7 items)