Modal Popup Extender with multiple TargetControlID??

Last post 11-30-2008 7:43 PM by nkew. 4 replies.

Sort Posts:

  • Modal Popup Extender with multiple TargetControlID??

    06-19-2007, 11:13 PM
    • Member
      point Member
    • Tatico
    • Member since 06-20-2007, 3:04 AM
    • Posts 1

     Hello, I'm new to the toolkit and I'm looking for ideas to accomplish  a  somewhat trivial goal.

    What I want is to show a panel in modal form base on the item chosen on a list.

    Imagine a list of employees and you want that when the user clicks on one of them a modal window comes up and allows the user to edit the chosen employee's data.

    the problem is that the ModalPopupExtender has room just for a single TargetControlID.

    Does anyone know a way to accomplish this?

     
    TIA 

  • Re: Modal Popup Extender with multiple TargetControlID??

    06-20-2007, 2:27 AM
    Answer
    • Member
      203 point Member
    • kylen
    • Member since 12-08-2006, 3:56 PM
    • Posts 48

    Yes I beleive you are correct in that the ModalPopupExtender allows only one TargetControlID, however you can have multiple ModalPopupExtenders on a page if you need multiple (different) Panels for input. 

    If you need only one Modal and want to show it from many different events you can create a button which will be shown as visible inline but on Page Load set the visibility to none and set it as your TargetControlID.  Then in any events you need the modal simply call ModalPopupExtender.show() method with 'ModalPopupExtender' being the ID of your extender.  The reason I say to leave the visibility set to true inline is I recently read a post where the Events were not getting attached at run time in some cases unless they were set to visible at compile time. If you take a look at the Sample code for the toolkit they have an example of this scenario.  Also keep in mind you might want to call the hide() method on the ModalPopupExtender when your finished with Input as some never get disposed and might cause problems next time you try to show one.

    Hope this helps...

  • Re: Modal Popup Extender with multiple TargetControlID??

    02-22-2008, 12:17 PM
    • Member
      36 point Member
    • groker
    • Member since 02-26-2007, 10:00 PM
    • Posts 19
    Thanks, your advice worked out well.  For those who haven't done this before, you must assign a behavior id to the popup extender, for example...

    <asp:LinkButton runat="server" ID="btnHiddenCompanyEmployeeController" />

    <ajax:ModalPopupExtender BackgroundCssClass="modalBackground" ID="popUpCompanyEmployee"
     
    runat="server" PopupControlID="panelCompanyEmployee"
     
    TargetControlID="btnHiddenCompanyEmployeeController" BehaviorID="popUpCompanyEmployeeBehavior">

    ...and call up the show function using the behavior id, for example...

    <asp:HyperLink runat="server" ID="HyperLink1" NavigateUrl="javascript:$find('popUpCompanyEmployeeBehavior').show();" Text="New Employee" />

     
  • Re: Modal Popup Extender with multiple TargetControlID??

    08-11-2008, 5:01 PM
    • Member
      4 point Member
    • Pjotr1001
    • Member since 08-11-2008, 8:56 PM
    • Posts 4

    there is an even simpler solution. Just asign a linkbutton to the TargetControlID, but don't assign any name to it, for example:

    <asp:LinkButton ID="Dummylinkbutton1" runat="server"></asp:LinkButton>

    you don't have to hide is linkbutton, cause it is already invisible, and you don't need a behaviourID or any javascript at al

  • Re: Modal Popup Extender with multiple TargetControlID??

    11-30-2008, 7:43 PM
    • Member
      4 point Member
    • nkew
    • Member since 12-18-2006, 4:33 AM
    • Posts 7

    Great tip. This worked perfectly for me.

    Nick

Page 1 of 1 (5 items)