关于遮挡层?

jianlicd79 2010-03-08 09:43:43
由于后台的数据处理量相当大,点击按钮后处理时间很长,
我想实现点击处理按钮后弹出一页面,等到处理完毕后再将弹出的页面关闭,请问如何实现?
...全文
138 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianlicd79 2010-03-08
  • 打赏
  • 举报
回复
请一楼的朋友写出具体的代码
jianlicd79 2010-03-08
  • 打赏
  • 举报
回复
顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶!
koukoujiayi 2010-03-08
  • 打赏
  • 举报
回复
最简单的是微软的AJAX控件
UpdateProgress就是干这件事的!!
chenyunkun2008 2010-03-08
  • 打赏
  • 举报
回复
建议用jquery吧
telankes2000 2010-03-08
  • 打赏
  • 举报
回复

function $(id) { return document.getElementById(id); }
var Mask = {
tempValue:{mask:null,msgMask:null},
DocBody:function(){return document.compatMode == "CSS1Compat" ? document.documentElement :document.body},
Width: function() { return this.DocBody().scrollWidth > this.DocBody().offsetWidth ? this.DocBody().scrollWidth : this.DocBody().offsetWidth; }, /*當前頁面的寬度(包括需要滚动的区域) */
Height: function() { return this.DocBody().scrollHeight > this.DocBody().offsetHeight ? this.DocBody().scrollHeight : this.DocBody().offsetHeight; }, /*當前頁面的高度(包括需要滚动的区域)*/
MiddleWidth: function() { return this.DocBody().offsetWidth / 2; }, /*獲取水平居中位置*/
MiddleHeight: function() { return this.DocBody().offsetHeight / 2 }, /*垂直居中位置 */
tempValue:{mask:null,msgMask:null},
createMask: function(posOptions) {/*創建遮罩層*/
if(this.tempValue.mask == null){
var _mask = document.createElement("div");
_mask.id = "mask";
var height = posOptions.height ? posOptions.height : this.Height(); //遮罩层的高度
var width = posOptions.width ? posOptions.width : this.Width();//遮罩层的寬度
var maskTop = posOptions.maskTop ? posOptions.maskTop : 0;
var maskLeft = posOptions.maskLeft ? posOptions.maskLeft : 0;
_mask.style.cssText = "display:block;position:absolute;z-index:2000;background-color:" + (posOptions.maskBgColor ? posOptions.maskBgColor : "#000") + ";width:" + width + "px;height:" + height + "px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);left:"+maskLeft+"px;top:"+maskTop+"px";
document.body.appendChild(_mask);
this.tempValue.mask = _mask;
}
},
createMsgMask: function(msg,posOptions) {/*創建信息提示層*/
if(this.tempValue.msgMask == null){
var _msgMask = document.createElement("div");
_msgMask.id = "maskmsg";
var msgTop = posOptions.msgTop ? posOptions.msgTop : this.MiddleHeight(); //信息提示層距离页面顶端的位置
var msgLeft = posOptions.msgLeft ? posOptions.msgLeft : this.MiddleWidth(); //信息提示層距离页面顶端的位置
_msgMask.style.cssText = "display:block;position:absolute;z-index:2001;color:red;text-align:center;ackground-color:#fff;font-size:9pt;top:" + msgTop + "px;left:" + msgLeft + "px;"; //background-image:url(../../Images/loading.gif);background-repeat:no-repeat
_msgMask.innerHTML = msg;
document.body.appendChild(_msgMask);
this.tempValue.msgMask = _msgMask;
}
},
initMask: function(msg, posOptions) {
var isShowMask = posOptions.isShowMask ? posOptions.isShowMask : true;//默認顯示遮罩層
this.createMask(posOptions);
this.createMsgMask(msg,posOptions);
if(isShowMask){
this.tempValue.mask.style.display = "block";
this.tempValue.msgMask.style.display = "block";
}
else{
this.tempValue.msgMask.style.display = "block";
this.tempValue.mask.style.display = "none";
}

},
/*
顯示狀態信息
isShow :是否顯示 必選
msg :要顯示的信息 必選
posOptions :可選
posOptions.maskBgColor : 遮罩層的背景色
posOptions.maskTop : --遮罩层距离页面顶端的位置
posOptions.maskLeft : --遮罩层距离页面左端的位置
posOptions.width : --寬度
posOptions.height : --高度
posOptions.msgTop : --信息提示層距离页面顶端的位置
posOptions.msgLeft : --信息提示層距离页面顶端的位置
posOptions.isShowMask : -- 是否顯示遮罩層 可選 默認為顯示
調用示例 :Mask.showStatusMessage(true,"加載中,請稍候...",{maskBgColor:"#fff",maskTop:0,maskLeft:0,width:800,height:600,msgTop:200,msgLeft:400})
*/
showStatusMessage: function(isShow,msg, posOptions) {
if (isShow) { this.initMask(msg, posOptions); }
else {
this.tempValue.mask.style.display = "none";
this.tempValue.msgMask.style.display = "none";
}
},
/*
延緩提交,顯示狀態信息
posOptions.seconds : 延緩時間 單位毫秒
*/
showMask: function(btn, msg,posOptions) {
this.showStatusMessage(true, msg, posOptions);
window.setTimeout(function() { $(btn).click(); }, posOptions.seconds ? posOptions.seconds : 1000 )
}
}
window.onload = function(){

if($("btnCheck")){
$("btnCheck").attachEvent("onclick",function(){Mask.showMask("Button1","數據正在提交中,請稍候...",{seconds:5000})})
}
}

<input type="button" value="提交" id="btnCheck" />
<asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" style="display:none"/>
xupeihuagudulei 2010-03-08
  • 打赏
  • 举报
回复
用微软提供的ajaxcontroltoolkit可以很方便实现

不过性能方面不知道怎么说。。
wang5225 2010-03-08
  • 打赏
  • 举报
回复
1楼正解。。 UpdateProgress就是用于在更新UpdatePanel中的数据时 显示提示信息的。。
不需要你写任何代码。 关于层的显示和隐藏 都是自动的
koukoujiayi 2010-03-08
  • 打赏
  • 举报
回复
引用 3 楼 jianlicd79 的回复:
请一楼的朋友写出具体的代码

代码基本是自动生成的!
    <form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div style="width: 200px; height: 50px; background-color: #cccccc;">
正在处理数据.....
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
    protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 100000000; i++)
{
}
}


为了使页面刷新别太快,在Button的click下,做空循环,
楼主可点击Button,看到"正在处理数据....."的层,回发结束后自动消失,
可以将这个层叠放在中央!!
zhangyumei 2010-03-08
  • 打赏
  • 举报
回复
关注,我也想知道怎么实现

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧