开发者

Multiple Target Id's and the ModalPopUp Extender

开发者 https://www.devze.com 2023-04-11 20:19 出处:网络
Evening all. Ok, here we go! Right I have the following buttons on my page and I wish to use one modal popup for both save clicks. I therefore have the following for the buttons:

Evening all.

Ok, here we go!

Right I have the following buttons on my page and I wish to use one modal popup for both save clicks. I therefore have the following for the buttons:

<asp:Button ID="btnSave1" runat="server" OnClick="btnSave1_Click"开发者_运维百科 Text="Save" OnClientClick="$find('showSaveConfirm').show(); return false;" />
<asp:Button ID="btnSave2" runat="server" OnClick="btnSave2_Click" Text="Save" OnClientClick="$find('showSaveConfirm').show(); return false;"/>

<asp:Button ID="btnSaveAll" runat="server" Text="" Style="display: none" />

And this below is my Modal panel info:

<asp:Panel ID="pnlSaveConfirm" runat="server" Style="display: none;" CssClass="modalPopupContainer">
            <div id="Div7" class="modalPopupHeaderPanel">
                <div id="Div8" class="modalPopupHeader">

                </div>
                <asp:LinkButton ID="LinkButton2" runat="server" CssClass="modalPopupClose" CausesValidation="False">Cancel and close</asp:LinkButton>
            </div>
            <div id="Div9" class="modalPopupBannerPanel">
                <div class="modalPopupPanel">
                        <br />
                        You are about to save this piece of data.
                        <asp:Button ID="btnOkSave" runat="server" Text="Ok" />
                        <asp:Button ID="btnCancelSave" runat="server" Text="Cancel" />
                        <br />
        </asp:Panel>
        <ajaxToolkit:ModalPopupExtender ID="mdlPopupSaveConfirm" runat="server" TargetControlID="btnSaveAll" BehaviorID="showSaveConfirm"
            OkControlID="btnOkSave" CancelControlID="btnCancelSave" PopupControlID="pnlSaveConfirm" BackgroundCssClass="modalBackground" />

Now both clicks fire off the one modal panel which is spot on. The cancels, cancel but there is one problem.

When I click on the btnOkSave, this does not appear to be confirming as the btnSave1_Click and btnSave2_Click server side events do not get fired off.

Any ideas what I have done wrong?


Well I actually went down a slightly different route and seeing as I was using the Ajax toolkit, I implemented the use of the ConfirmButtonExtender.

For the two original saves, I set up two seperate ModalPopUpExtenders pointing at the same panel, these being executed by the ConfirmButton Extender:

  <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" 
                    runat="server" ConfirmText="" Enabled="True" TargetControlID="btnSave1" DisplayModalPopupID="mdlPopupSave1Confirm">
                </ajaxToolkit:ConfirmButtonExtender>
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender2" 
                    runat="server" ConfirmText="" Enabled="True" TargetControlID="btnSave2" DisplayModalPopupID="mdlPopupSave2Confirm">
                </ajaxToolkit:ConfirmButtonExtender>

With these attached to the actual panel:

<ajaxToolkit:ModalPopupExtender ID="mdlPopupSave1Confirm" runat="server" TargetControlID="btnSave1"
             OkControlID="btnOkSave" CancelControlID="btnCancelSave"
            PopupControlID="pnlSaveConfirm" BackgroundCssClass="modalBackground" />
            <ajaxToolkit:ModalPopupExtender ID="mdlPopupSave2Confirm" runat="server" TargetControlID="btnSave2"
             OkControlID="btnOkSave" CancelControlID="btnCancelSave"
            PopupControlID="pnlSaveConfirm" BackgroundCssClass="modalBackground" />

And that has achieved exactly what I am looking to do.

Still dirty but it works : )


There is no OnClick event for btnOkSave. Add this to your control:

OnClick="btnSave1_Click"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号