我正在使用此代码显示一个确认删除按钮的对话框,它工作正常,但是当它弹出时它不会禁用ASP.Net页面的任何控件,所以我可以点击任何一个控件或文本框,
我想做的第一件事是当Jquery打开我的Div标签BOX时淡出页面,然后禁用所有控件。
这是代码
Div(自定义对话框)
<div id="divConfMessage">
<div align="center">
<br /><asp:Label ID="Label1" runat="server" Text="Deleting this eDecision will remove all site content and uploaded documents. Are you sure you wish to continue?" CssClass="headertext"></asp:Label><br /><br /><br /><br /><br />
<asp:Button ID="btnConfOK" Width="200px" Height="25px" CssClass="gradientbutton" OnClick="btDelete_Click" Runat="server" Text="Yes"></asp:Button>
<asp:Button ID="btnConfCancel" Width="200px" Height="25px" CssClass="gradientbutton" Runat="server" Text="No"></asp:Button><br /><br /><br />
</div>
</div>
脚本(jquery)
<script type="text/javascript" src="/_layouts/1033/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("input[id$='btDelete']").click(function()
{
$("#divConfMessage").fadeIn();
});
});
</script>
按钮
<td>
<asp:Button ID="btDelete" runat="server" CssClass="gradientbutton" OnClick="btDelete_Click"
OnClientClick="this.disabled=true;this.value='Please Wait...';" Text="Delete" Width="200px" />
</td>
Css for Dialog Box
#divConfMessage
{
position: absolute;
width: 500px;
height: 200px;
top: 50%;
left: 30%;
margin-left: -150px; /* Negative half of width. */
margin-top: -100px; /* Negative half of height. */
border: 2px solid #000;
DISPLAY:none;
background-color:White;
line-height:20px;
text-align:center;
}
注意
除了CSS之外,所有代码都在用于页面的ASP内容占位符中,我有另外两个具有不同控件的内容+一个定义所有这些内容占位符的母版页。
<asp:Content ID="Content4" ContentPlaceHolderID="cphSubmit" runat="server">
<%@ Page Language="C#" MasterPageFile="~/my.Master" AutoEventWireup="true" CodeBehind="c.aspx.cs" Inherits="a.b.c" Title="e" meta:resourcekey="PageResource1" %>
答案 0 :(得分:1)
设置Modal = true;对于dilogbox,有模态属性,你可以将它设置为True。
尝试使用Jquery dialogue box(它附带JqueryUI插件)。
$( "#YourDivorContainerToShowAsDialog" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
EDIt:如果你不想使用按钮,那就像这样使用
$( "#YourDivorContainerToShowAsDialog" ).dialog({
modal: true
});
或者如果您想使用CSS,那么您可以尝试
#YourDivorContainerToShowAsDialog
{
position: absolute;
Z-index: withMaxValue
}
答案 1 :(得分:1)
为Z-index
提供更高的 #divConfMessage
,然后模式dalog将位于最重要的位置。
当您添加对话框时,将其附加到正文:
add_block_page();
add_modal_box();
function add_block_page(){
var block_page = $('<div class="page"></div>');
$(block_page).appendTo('body');
}
function add_modal_box(){
var pop_up = $('<div id="divConfMessage"></div>');
$(pop_up).appendTo('.page');
}
答案 2 :(得分:0)
使用一个透明图片淡出页面。
添加一个outerDiv并将图像应用于div。
<div id="outerDiv" style="display:none;">
<div id="divConfMessage">
<div align="center">
<br /><asp:Label ID="Label1" runat="server" Text="Deleting this eDecision will remove all site content and uploaded documents. Are you sure you wish to continue?" CssClass="headertext"></asp:Label><br /><br /><br /><br /><br />
<asp:Button ID="btnConfOK" Width="200px" Height="25px" CssClass="gradientbutton" OnClick="btDelete_Click" Runat="server" Text="Yes"></asp:Button>
<asp:Button ID="btnConfCancel" Width="200px" Height="25px" CssClass="gradientbutton" Runat="server" Text="No"></asp:Button><br /><br /><br />
</div>
</div>
</div>
outerDiv的CSS
# outerDiv
{
top:0%;
left:0%;
position:absolute;
background-image:url('../img/FloatingPanel.png');//transperant image
color:White;
z-index: 1102;
Height:100%;
width:100%;
}
为#divConfMessage提供比outerDiv的Z-index更高的Z-index(即:1103)。 显示btDelete
的outerDiv onclick