locked
Multiple buttons associated with a single ModalPopupExtender RRS feed

  • Question

  • User1396448631 posted

    Hi,

    Is it possible to have many buttons associated with a single ModalPopupExtender?

    <asp:Button ID="btnPopup" runat="server" Text="PopUp" style = "display:none" /> // default control
    <asp:Button ID="Button1" runat="server" CssClass="btn btn-primary" 
                                Height="200px" Width="200px" onclick="Button1_Click" />
    <asp:Button ID="Button2" runat="server" CssClass="btn btn-primary" 
                                Height="200px" Width="200px" onclick="Button2_Click" />
    <asp:ModalPopupExtender ID="mpe" runat="server" BackgroundCssClass="modalBackground" PopupControlID="pnlPopup" TargetControlID="btnPopup" />
    
            <asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display: none">
    
            // I will have updatepanel where content will change based on which button is clicked
    
            </asp:Panel>
    protected void Button1_Click(object sender, EventArgs e)
    {
         mpe.TargetControlID = "Button1";
    }
    
    protected void Button2_Click(object sender, EventArgs e)
    {
         mpe.TargetControlID = "Button2";
    }

    This doesn't seem to work.

    Thank you!

    Monday, April 4, 2016 5:24 PM

Answers

  • User61956409 posted

    Hi dbqasp,

    TargetControlID property could specify the ID of the element that activates the modal popup. If you’d like to dynamically open ModalPopupExtender, why not using

    mpe.Show();

    to open the Modal Popup.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 5, 2016 3:19 AM