多个目标 ID 和 ModalPopUp 扩展器

发布于 2024-12-09 14:49:53 字数 1893 浏览 0 评论 0原文

晚上大家。

好的,我们开始吧!

是的,我的页面上有以下按钮,我希望使用一个模式弹出窗口来进行两次保存点击。因此,我对按钮有以下内容:

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

下面是我的模态面板信息:

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

现在,两次单击都会触发一个恰到好处的模态面板。取消了,取消了,但是有一个问题。

当我单击 btnOkSave 时,这似乎并未得到确认,因为 btnSave1_Click 和 btnSave2_Click 服务器端事件不会被触发。

有什么想法我做错了什么吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心意如水 2024-12-16 14:49:53

事实上,我走了一条稍微不同的路线,因为我使用的是 Ajax 工具包,所以我实现了 ConfirmButtonExtender 的使用。

对于两个原始保存,我设置了两个指向同一面板的单独的 ModalPopUpExtender,它们由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>

将它们附加到实际面板:

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

这已经实现了我想要做的事情。

仍然很脏,但它有效:)

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

A君 2024-12-16 14:49:53

btnOkSave 没有 OnClick 事件。将其添加到您的控件中:

OnClick="btnSave1_Click"

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

OnClick="btnSave1_Click"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文