在后面的代码中使用 .show() 时,我在显示 modalpopupextender 时遇到问题。
使用链接按钮时,模态弹出窗口完全按预期工作,但是当我从后面的代码调用它时,弹出窗口不是模态的,我可以在文本框中输入数据,单击其他按钮等。注意链接按钮通常会被隐藏样式=“显示:无;”。
我正在尝试设置弹出窗口以根据单击的按钮显示一条消息。
我已经复制了下面的代码(删除了额外的表格细节以节省空间)。
<%@ 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 天我一直在寻找答案,现在完全陷入困境。任何帮助或指导将不胜感激。