我在使用代碼中的.show()代碼時顯示modalpopupextender時出現問題。modalpopupextender在使用.show時無法識別BackgroundCssClass()
當使用鏈接按鈕時,模式彈出窗口完全按照預期工作,但是當我從後面的代碼調用它時,彈出窗口不是模態的,我可以在文本框中輸入數據,單擊其他按鈕等。通常隱藏 與style =「display:none;」。
我想設置彈出窗口來顯示一個消息取決於哪個按鈕被點擊。
我已經複製了下面的代碼(刪除了多餘的表格詳細信息以節省空間)。
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FrmTransaction.aspx.cs" Inherits="Cloud9.FrmTransaction" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
<div runat="server" id="PageDetailDiv" class="pagedetail">
<asp:ValidationSummary runat="server" />
<asp:Table runat="server" HorizontalAlign="Center" Width="80%">
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Label runat="server" ID="lblMsg" CssClass="Msg" EnableViewState="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="trSearch" runat="server">
<asp:TableCell runat="server">
<div align="left">
<asp:Label CssClass="formCapture" Text='Field' runat="server" ID="lblSearchField" AssociatedControlID="tbSearchField" />
<obout:OboutTextBox FolderStyle="Styles/Obout/TextBox" runat="server" ID="tbSearchField" Width="300px" />
<br />
<asp:Label CssClass="formCapture" Text='Lookup' runat="server" ID="lblSearch" AssociatedControlID="tbSearch" />
<obout:OboutTextBox FolderStyle="Styles/Obout/TextBox" runat="server" ID="tbSearch" Width="300px" />
<asp:Button ID="SearchButton" runat="server" Text="Find" CommandName="Search" CausesValidation="False"
OnCommand="btnClick_Search" CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'" />
</div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table runat="server" HorizontalAlign="Center" Width="80%">
<asp:TableRow ID="trButton" runat="server">
<asp:TableCell>
<div align="center">
<asp:Button id="btnInsert" runat="server" Text="Insert" CommandName="Insert" CausesValidation="True" OnCommand="btnClick_Insert"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
<asp:Button id="btnUpdate" runat="server" Text="Update" CommandName="Update" CausesValidation="True" OnCommand="btnClick_Update"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
<asp:Button id="btnDelete" runat="server" Text="Delete" CommandName="Delete" CausesValidation="False" OnCommand="btnClick_Delete"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
<asp:Button id="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="False" OnCommand="btnClick_Cancel"
CssClass="btnDefault" onMouseOver="this.CssClassName='btnDefaultHover'" onMouseOut="this.CssClassName='btnDefault'"/>
</div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Panel CssClass="modalPopup" runat="server" ID="pnlMessage" >
<asp:Label runat="server" ID = "lblMessg" />
<br />
<asp:Button id="btnOKMessage" Text="OK!" Runat="server" UseSubmitBehavior="false" CausesValidation="false" OnCommand="btnClick_Cancel"
class="btnPgeSmall" onMouseOver="this.className='btnPgeSmallHover'" onMouseOut="this.className='btnPgeSmall'" />
</asp:Panel>
<asp:LinkButton ID="UsedByModal" Text="here" runat="server" />
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="pnlMessage" TargetControlID="UsedByModal"
BackgroundCssClass="modalBackground" CancelControlID="btnOKMessage" OkControlID="btnOKMessage" />
</div>
</asp:Content>
的CSS的相關部分.....
.modalBackground {
background-color:Gray;
filter:alpha(opacityp);
opacity:0.7;
}
.modalPopup {
background-color:#F6F6EA;
border-width:3px;
border-style:solid;
border-color:#c0c0c0;
padding:3px;
width:50%;
}
我一直在尋找最近3天的答案和現在完全被卡住。任何幫助或指導,將不勝感激。
謝謝我試着用你的替換我的班,並收到相同的結果。問題是,由於某種原因,當我使用鏈接按鈕以外的任何其他控件時,頁面根本無法識別該類。通過不識別modalBackground類,它不會將彈出窗口格式化爲模態。 – NickD61
試試這個ModalPopupExtender1.BackgroundCssClass =「modalBackground」;在代碼隱藏之前展示。 –