"multiple TargetControlIDs" for ModalPopupExtender ?

Last post 06-01-2009 10:48 AM by shoaib.mehmood. 8 replies.

Sort Posts:

  • "multiple TargetControlIDs" for ModalPopupExtender ?

    12-31-2006, 6:02 AM
    • Member
      20 point Member
    • d.v
    • Member since 10-19-2006, 9:51 AM
    • Posts 11

    Hi,

    Is it possible to have the ModalPopupExtender triggered to popup by more than one control? I know you can only set one TargetControlID but is there any way around it so several buttons on the page will make it popup?

    Thanks.

    -dv
     

  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    12-31-2006, 4:38 PM
    • Contributor
      2,019 point Contributor
    • Jason Hill
    • Member since 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 479
    Just copy the ModalPopupExtender for each control that will invoke the modal popup.  The CTP versions of the toolkit allowed for multiple controls to be hooked up to a single extender but this was deemed too complex.
  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    01-01-2007, 5:25 AM
    • Member
      20 point Member
    • d.v
    • Member since 10-19-2006, 9:51 AM
    • Posts 11

     Hi, 

    Yes, multiple ModalPopupExtenders is an option but the thing is, I already have few of them on the form opening different popups which I switch back and forth programmatically.  If I can avoid it, I'd rather not add additional extenders for this purpose.

    I was hoping there was a way to elegantly duplicate how the toolkit handles the TargetControl to additional controls and make them operate on the same ModalPopupExtender. 

    Possible? Any pointers to the right direction are welcome. Thanks. 

    - dv 

  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    01-01-2007, 6:40 AM
    • Contributor
      2,019 point Contributor
    • Jason Hill
    • Member since 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 479

    ASAIK, the footprint of each ModalPopup is pretty small so I don't think there is a big problem with having a lot of them on a page.  If you really are keen to minimise the number of extenders on the page, then you can do some more stuff on the client side.  Create a single extender and then use other controls on the page to open the same ModalPopup by calling the clientside JS show() method on the ModalPopup control.  The only thing to be aware of is the need to reference the ModalPopup by a clientside ID (ClientID property).

  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    01-01-2007, 6:57 AM
    • Member
      20 point Member
    • d.v
    • Member since 10-19-2006, 9:51 AM
    • Posts 11

    My problem is not with the footprint but as I said, I already have a bunch of them on the page and I manipulate their show/hide manually based on user interaction so adding additional extenders will just complicate things for me.

    Calling show/hide myself from other buttons On Click is probably what I will end up doing if I don't find a more elegant way. 

     
    But how does the toolkit knows to wire the TargetControl so that it is hooked to show the popup? I didn't see any java script added to the control, is it somehow handled in the form.onsubmit? Can't I just mimic this mechanism? How?

    Thanks. 

     

  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    01-01-2007, 7:27 AM
    • Contributor
      2,019 point Contributor
    • Jason Hill
    • Member since 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 479

    Check out the source for your page and towards the bottom you will see some JS calls to create the ModalPopupBehavior's.  This really just wires up the open and close controls for the ModalPopup so not much more than simple JS event handlers for the appropriate clicks.

    I certainly share your use case of having multiple controls that can open a ModalPopup but for me creating multiple extenders was OK and really no burden other than a few lines of code.  If I wanted to programatically limit what the UI needed to do, I just make some controls invisible which also disables any associated ModalPopup.  I also do stuff with the ModalPopups server side occasionally when the logic gets really tricky although that obviously incurs a performance penalty, ie. you can always call Show() and Hide() server side.

    A final option that I can think of is to extend the ModalPopup and allow for multiple target controls to be assigned although this seems like a lot of work for something that can be achieved via other methods.

  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    01-04-2007, 8:54 AM
    • Member
      20 point Member
    • d.v
    • Member since 10-19-2006, 9:51 AM
    • Posts 11

    Thanks for the reply.

    I tried to hooking up additional buttons by creating additional behaviors with

    Sys.Application.add_init(function() {
        $create(AjaxControlToolkit.ModalPopupBehavior, {...}));
    });


    but this seems to override the previous buttons hooked by setting the TargetControlID. I can't seems to be able to make multiple buttons to work.

    Can anyone suggest code that will make it work?

    Thanks. 

  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    01-04-2007, 2:37 PM
    • Contributor
      2,019 point Contributor
    • Jason Hill
    • Member since 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 479

    Set the Button onclick JS to:

    $find('ModulePopupClientID').show();

  • Re: "multiple TargetControlIDs" for ModalPopupExtender ?

    06-01-2009, 10:48 AM
    • Member
      9 point Member
    • shoaib.mehmood
    • Member since 03-27-2008, 6:38 AM
    • Mehmood
    • Posts 18
    In my case i have found a solution which may not be as elegant but works perfectly fine for me. Actually i want to show the modal popup manually in the button click event after doing some processing. If i leave the TargetControlID of MPE, it gives error. As a workaround, I have created a dummy image button that shows a 1 pixel blank image. The modal popup extender's target control ID is set to this dummy image's ID. I have 3 more image buttons. In each button's onclick event, i display the popup by calling ModalPopupExtender1.Show(); Honestly speaking i would have loved a more elegant solution but for the time being, this works for me pretty well.
    Shoaib Mehmood
    IT Consultant
    Techweavers
    www.tech-weavers.com
Page 1 of 1 (9 items)