如何检测当前是否正在使用javascript显示modalpopupextender?
Modalpopupextender标记
<!-- Add Files Modal Form -->
<asp:HiddenField ID="AddFilesForModal" runat="server" />
<ajaxToolkit:ModalPopupExtender runat="server" ID="AddFilesModal" BehaviorID="modalPopupExtenderAddFiles"
TargetControlID="dummyButtonAddToPendingList" PopupDragHandleControlID="PanelAddFilesOuter" PopupControlID="PanelAddFilesOuter"
OkControlID="dummyButtonAddToPendingList" BackgroundCssClass="modalBackground" DropShadow="false"
Drag="true">
</ajaxToolkit:ModalPopupExtender>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender4" runat="server" TargetControlID="PanelAddFilesInner">
</ajaxToolkit:RoundedCornersExtender>
<asp:Panel ID="PanelAddFilesOuter" runat="server" BackColor="Transparent" Style="display: none;">
<asp:Panel ID="PanelAddFilesInner" runat="server" BackColor="White" Style=" width:800px; height:600px; overflow:auto;">
<ContentTemplate>
<div id="AddFilesContainer" style=" padding-left:10px; padding-right:10px; padding-top:10px; padding-bottom:5px;">
<br />
Add Files
<div id="AddFiles_Div" style="height:80%;overflow:auto;">
<asp:TreeView ID="TreeViewAddItems" runat="server" Height="500px" ShowCheckBoxes="Leaf"
Width="380px" ImageSet="XPFileExplorer" NodeIndent="15" PathSeparator="\" ShowExpandCollapse="true"
EnableClientScript="true" OnTreeNodeCheckChanged="OnTreeNodeCheckChanged" OnAdaptedTreeNodeCheckChanged="OnTreeNodeCheckChanged" ShowLines="True">
<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="2px"
NodeSpacing="0px" VerticalPadding="2px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" HorizontalPadding="0px"
VerticalPadding="0px" />
</asp:TreeView>
</div>
<br />
<div class="base" style="height:20px;">
<asp:LinkButton ID="lnkAddToPendingList" runat="server" OnClick="BtnAddToPendingList_Click" BorderStyle="Solid" BackColor="#CCCCCC">Add selected items to list</asp:LinkButton>
<asp:Button CssClass="Button" ID="dummyButtonAddToPendingList" runat="server" Style="display: none;" />
<asp:Button CssClass="Button" ID="CancelAddFiles" runat="server" Text="Cancel" OnClientClick="$find('modalPopupExtenderAddFiles').hide(); return false;" />
</div>
</div>
</ContentTemplate>
</asp:Panel>
</asp:Panel>
<!-- End Add Files Modal Form -->
答案 0 :(得分:2)
我认为你可以打电话给我。您可能需要挂钩显示和隐藏事件。像这样:
var amIVisible = false;
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function () {
$find('modalPopupExtenderAddFiles').add_shown(function () {
amIVisible = true;
});
$find('modalPopupExtenderAddFiles').add_hidden(function () {
amIVisible = false;
});
});
答案 1 :(得分:1)
使用BehaviourID在客户端进行验证:
<script type="text/javascript">
function IsVisible()
{
var modalPopup = $find('ModalBehaviourID');
return modalPopup ? true : false;
}
</script>
第二个选项:
<script type="text/javascript" >
function IsVisible()
{
return $find('ModalBehaviourID').get_PopupVisible();
}
</script>
来源:Link