更新面板内弹出的模式没有响应

发布于 2024-12-11 02:09:21 字数 3355 浏览 0 评论 0原文

<asp:ModalPopupExtender ID="MPE_EditGroup" runat="server" TargetControlID="btnShowPopup"
                    PopupControlID="pnlpopup" DropShadow="true" BackgroundCssClass="modalBackground" />   
 <asp:Panel ID="pnlpopup" runat="server" > 
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
                            <ContentTemplate>
                                <table width="100%" style="border: Solid 3px #980000; width: 470px; height: 370px;"
                                    cellpadding="0" cellspacing="0">
                                                                   <tr>
                                        <td align="center">

                                            <asp:ListBox ID="lst_allmembers" SelectionMode="Multiple" Width="120px" ToolTip="Press ctrl to select multiple users"
                                                DataValueField="FirstName" runat="server"></asp:ListBox>
                                            <asp:Button ID="btn_Add" runat="server" Text="Add User" OnClick="btn_Add_Click" />
                                        </td>
                                        <td align="center">

                                            <asp:ListBox ID="lst_grpmembers" DataValueField="Name" SelectionMode="Multiple" Width="120px"
                                                ToolTip="Press ctrl to select multiple users" runat="server"></asp:ListBox>
                                            <asp:Button ID="btn_remove" runat="server" Text="Remove User" OnClick="btn_Remove_Click" />
                                        </td>
                                    </tr>
                                  <tr><td></td><td></td></tr>
                                    <tr>
                                        <td align="right">
                                            <asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" OnClick="btnUpdate_Click" />
                                        </td>
                                        <td align="left">
                                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="Cancel_Click" />
                                        </td>
                                    </tr>
                                </table>
                            </ContentTemplate>

                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="btn_Add" EventName="Click" />
                                <asp:AsyncPostBackTrigger ControlID="btn_remove" EventName="Click" />
                               </Triggers>
                              </asp:UpdatePanel><asp:Panel>

我在更新面板中有这个表,添加和删除工作正常,但更新按钮没有响应,但代码被执行,一切都很好。但它必须关闭模式弹出窗口并显示警报,但它没有发生。如果我在单击更新按钮时进行重定向,它就会起作用。但我想显示一个警报,然后绑定表。应该做什么

更新代码隐藏

 Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript", "alert(\"Group successfully updated\");", true);
        BindGridView(Session["useremail"].ToString());
<asp:ModalPopupExtender ID="MPE_EditGroup" runat="server" TargetControlID="btnShowPopup"
                    PopupControlID="pnlpopup" DropShadow="true" BackgroundCssClass="modalBackground" />   
 <asp:Panel ID="pnlpopup" runat="server" > 
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
                            <ContentTemplate>
                                <table width="100%" style="border: Solid 3px #980000; width: 470px; height: 370px;"
                                    cellpadding="0" cellspacing="0">
                                                                   <tr>
                                        <td align="center">

                                            <asp:ListBox ID="lst_allmembers" SelectionMode="Multiple" Width="120px" ToolTip="Press ctrl to select multiple users"
                                                DataValueField="FirstName" runat="server"></asp:ListBox>
                                            <asp:Button ID="btn_Add" runat="server" Text="Add User" OnClick="btn_Add_Click" />
                                        </td>
                                        <td align="center">

                                            <asp:ListBox ID="lst_grpmembers" DataValueField="Name" SelectionMode="Multiple" Width="120px"
                                                ToolTip="Press ctrl to select multiple users" runat="server"></asp:ListBox>
                                            <asp:Button ID="btn_remove" runat="server" Text="Remove User" OnClick="btn_Remove_Click" />
                                        </td>
                                    </tr>
                                  <tr><td></td><td></td></tr>
                                    <tr>
                                        <td align="right">
                                            <asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" OnClick="btnUpdate_Click" />
                                        </td>
                                        <td align="left">
                                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="Cancel_Click" />
                                        </td>
                                    </tr>
                                </table>
                            </ContentTemplate>

                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="btn_Add" EventName="Click" />
                                <asp:AsyncPostBackTrigger ControlID="btn_remove" EventName="Click" />
                               </Triggers>
                              </asp:UpdatePanel><asp:Panel>

I have this table inside the update panel, and the add and remove works fine, but the update button doesnt respond, but the code is executed and everything is fine. but it has to close the modal pop up and display a alert, but it is not happening. If i do redirect when I click the update button it works. but I want to show a alert and then bind the table. what should be done

Code behind for update

 Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript", "alert(\"Group successfully updated\");", true);
        BindGridView(Session["useremail"].ToString());

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

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

发布评论

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

评论(1

心意如水 2024-12-18 02:09:21

您可能在复制时遗漏了一些内容,但 ModalPopupExtender 未正确关闭:

<asp:ModalPopupExtender ID="MPE_EditGroup" runat="server" 
    TargetControlID="btnShowPopup" 
    PopupControlID="pnlpopup" 
    DropShadow="true" 
    BackgroundCssClass="modalBackground" /> 

至于关闭 Popup 并在单击更新按钮时显示警报,请尝试对更新按钮使用 PostBackTrigger。

<asp:PostBackTrigger ControlID="btnUpdate" EventName="Click" />  

这将使按钮执行完整的回发,这将关闭弹出窗口,并允许您在页面重新加载时显示警报。

You might have missed something when copying it, but the ModalPopupExtender isn't closed properly:

<asp:ModalPopupExtender ID="MPE_EditGroup" runat="server" 
    TargetControlID="btnShowPopup" 
    PopupControlID="pnlpopup" 
    DropShadow="true" 
    BackgroundCssClass="modalBackground" /> 

As for closing the Popup and displaying an alert when the update button is clicked, try using a PostBackTrigger for the update button.

<asp:PostBackTrigger ControlID="btnUpdate" EventName="Click" />  

This will make the button perform a full postback, which will close the popup, and allow you to show the alert when the page reloads.

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