ModalPopupExtender z-index 值在每次显示后都会减小

发布于 2024-08-29 21:21:51 字数 3210 浏览 4 评论 0原文

这是我以前从未见过的新事物。我有一个包含一堆类别的网格视图,可以通过单击网格视图中相应的“编辑”链接来编辑这些类别。然后以编程方式显示 modalpopupextender(.show() 方法),并且允许用户编辑类别。然后,当用户按下“更新”或“取消”时,以编程方式隐藏模式弹出窗口(.hide() 方法)。由于某种原因,每次新显示模态弹出窗口后,z-index 都会减少 1000,直到隐藏在页面上的所有内容后面。第一场演出起价为7000。因此,如果用户愿意,他们将无法编辑无限数量的类别。有什么想法为什么会发生这种情况吗?

modalpopupextender 上使用的 CSS 类:

DIV.box-pop
{
    border: #95aab9 1px solid;
    background-color: #ECF1F5;
    display: block;
    position: relative;
    margin: -6px 6px 6px -6px;
    padding: 4px;
    z-index: 10000;
}

用于弹出的面板:

<asp:Panel ID="PanelModify" runat="server" Width="250px" CssClass="box-pop">
    <asp:UpdatePanel ID="UpdatePanelModify" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <table width="100%" cellpadding="3" cellspacing="3">
                <tr>
                    <td>
                        <div class="box">
                            <h1>
                                <span><strong>
                                    <asp:Literal ID="LiteralModalTitle" runat="server" /></strong></span>
                            </h1>
                            <table border="0" width="100%">
                                <tr>
                                    <td>
                                        <asp:TextBox ID="TextBoxModifiedText" runat="server" Width="173px" ValidationGroup="Modify"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorModifiedText" runat="server"
                                            ValidationGroup="Modify" ErrorMessage="*" ControlToValidate="TextBoxModifiedText"
                                            Display="Dynamic">
                                        </asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Button ID="ButtonUpdate" runat="server" Text="Update" ValidationGroup="Modify" /><asp:Button
                                            ID="ButtonInsert" runat="server" Text="Insert" ValidationGroup="Modify" />
                                        &nbsp;
                                        <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" CausesValidation="false" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderModify" runat="server" PopupControlID="PanelModify"
    TargetControlID="ButtonHideModify" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="ButtonHideModify" runat="server" Style="display: none;" />

This is a new one I have never seen before. I have a gridview containing a bunch of categories that can be edited by clicking on the respective "Edit" link within the gridview. The modalpopupextender is then shown programmatically (.show() method) and the user is allowed to edit the category. Then the modal popup is programmtically hidden (.hide() method) when the user presses "Update" or "Cancel". For some reason after every new show of the modal popup, the z-index is decreasing by 1000 until it is hidden behind everything on my page. It starts at 7000 for the very first show. Therefore the user would not be able to edit an infinite number of categories if they wanted to. Any ideas why this is happening?

Css class used on modalpopupextender:

DIV.box-pop
{
    border: #95aab9 1px solid;
    background-color: #ECF1F5;
    display: block;
    position: relative;
    margin: -6px 6px 6px -6px;
    padding: 4px;
    z-index: 10000;
}

Panel used for popup:

<asp:Panel ID="PanelModify" runat="server" Width="250px" CssClass="box-pop">
    <asp:UpdatePanel ID="UpdatePanelModify" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <table width="100%" cellpadding="3" cellspacing="3">
                <tr>
                    <td>
                        <div class="box">
                            <h1>
                                <span><strong>
                                    <asp:Literal ID="LiteralModalTitle" runat="server" /></strong></span>
                            </h1>
                            <table border="0" width="100%">
                                <tr>
                                    <td>
                                        <asp:TextBox ID="TextBoxModifiedText" runat="server" Width="173px" ValidationGroup="Modify"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorModifiedText" runat="server"
                                            ValidationGroup="Modify" ErrorMessage="*" ControlToValidate="TextBoxModifiedText"
                                            Display="Dynamic">
                                        </asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Button ID="ButtonUpdate" runat="server" Text="Update" ValidationGroup="Modify" /><asp:Button
                                            ID="ButtonInsert" runat="server" Text="Insert" ValidationGroup="Modify" />
                                         
                                        <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" CausesValidation="false" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderModify" runat="server" PopupControlID="PanelModify"
    TargetControlID="ButtonHideModify" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="ButtonHideModify" runat="server" Style="display: none;" />

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

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

发布评论

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

评论(2

撕心裂肺的伤痛 2024-09-05 21:21:51

发现问题了。我用于弹出窗口的面板位于另一个更新面板内。我将其移到更新面板之外,z-index 不再改变。

Found the problem. The panel I was using for the pop-up was inside another update panel. I moved it outside of the update panel and the z-index is no longer changing.

奈何桥上唱咆哮 2024-09-05 21:21:51

我有一个 UpdatePanel,其中有一个 ModalPopupExtender。每当我第七次打开弹出窗口时,网站的布局就会变得混乱。所以这似乎是 z-index 的问题,每次弹出窗口打开时它都会小于特定值(即小于 0)。修复程序在这里找到:AJAX ModalPopup Pops Behind(在) 页面内容(负 z 索引)

.ModalPopup {
    z-index: 6001 !important;
}
.ModalPopupBackground {
    z-index: 6000 !important;
}

ModalPopupBackground 类应用于 ModalPopupExtender BackgroundCssClass 属性。 ModalPopup 类应用于 asp:Panel CssClass 属性。

I have an UpdatePanel with within it a ModalPopupExtender. Every seventh time I opened the popup the layout in the site was messed up. So it appeared to be a problem with the z-index, it became less than a specific value (i.e. less than 0) every time the popup opened. The fix was found here: AJAX ModalPopup Pops Behind (Under) Page Content (Negative z-index).

.ModalPopup {
    z-index: 6001 !important;
}
.ModalPopupBackground {
    z-index: 6000 !important;
}

The ModalPopupBackground class is applied to the ModalPopupExtender BackgroundCssClass attribute. The ModalPopup class was applied tot the asp:Panel CssClass attribute.

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