Associating multiple buttons with a single modalpopupextender

时间:2016-04-04 17:44:42

标签: ajaxcontroltoolkit

Is it possible to have several buttons associated with a single modalpopupextender?

 <asp:Button ID="btnPopup" runat="server" Text="PopUp" style = "display:none" />
 <asp:Button ID="Button1" runat="server" CssClass="btn btn-primary" onclick="Button1_Click" />
 <asp:Button ID="Button2" runat="server" CssClass="btn btn-primary" onclick="Button2_Click" />

 <asp:ScriptManager ID="ScriptManager1" runat="server" />

 <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>

In code behind

    protected void Button1_Click(object sender, EventArgs e)
    {
        mpe.TargetControlID = "Button1";
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        mpe.TargetControlID = "Button2";
    }

1 个答案:

答案 0 :(得分:1)

不,您无法将多个按钮与单个ModalPopupExtender相关联,因为它只有一个目标控件。

但是,您可以使用PopupControlID属性指向单个弹出控件。