您的位置:首页 > 编程语言 > ASP

asp.net 按钮执行添加遮盖层

2013-10-08 13:58 811 查看
1.js代码
var coverLayer = {
divObj : null,
_coverTime : null,

// _coverRe : function()
// {//刷新遮盖层
//   this.divObj.style.width = window.screen.availWidth + "px";
//   this.divObj.style.height = window.screen.availHeight + "px";
// },

on : function(noSave)
{ //打开遮盖层
if(this.divObj == null)
{
this.divObj = document.createElement("div");
this.divObj.style.zIndex = 10000;
this.divObj.id='divObj';
this.divObj.style.position = "absolute";
this.divObj.style.left = '0px';
this.divObj.style.top = '0px';
this.divObj.style.right = '-20px';
this.divObj.style.backgroundColor = "#DDDDDD";
this.divObj.style.fontSize = "x-large";
this.divObj.style.textAlign ="center";

this.divObj.innerText="处理中...";

var tempFrame = document.createElement("iframe");
tempFrame.style.filter = "Alpha(Opacity=0)";
tempFrame.frameBorder=0;
tempFrame.scrolling="no";
tempFrame.style.width = "100%";
tempFrame.style.height = "100%";
//   tempFrame.style.position = "absolute";
//   tempFrame.style.zIndex = -1;
//   tempFrame.style.visibility="inherit";
//   tempFrame.style.left = '0px';
//   tempFrame.style.top = '0px';

this.divObj.appendChild(tempFrame);
this.divObj.style.filter = "Alpha(Opacity=80)";

document.body.appendChild(this.divObj);
};
this.divObj.style.width =  document.documentElement.clientWidth + "px";
this.divObj.style.height =  document.documentElement.clientHeight + "px";
this.divObj.style.paddingTop =document.documentElement.clientHeight / 2 + "px";

this.divObj.style.display = "block";
// clearInterval(this._coverTime);
//this._coverTime = setInterval("coverLayer._coverRe()",1);
},

off : function(noSave)
{ //关闭遮盖层
if(this.divObj){this.divObj.style.display = "none"};
//clearInterval(this._coverTime);
}
}

2.asp.net 通用事件添加

''' <summary>
''' 通用事件添加
''' </summary>
''' <param name="oControl">控件容器</param>
''' <remarks></remarks>
Public Shared Sub LoopingControlsShowDiv(ByVal oControl As Control)
Dim frmCtrl As Control
For Each frmCtrl In oControl.Controls
'If TypeOf frmCtrl Is TextBox Then
'End If
'If TypeOf frmCtrl Is DropDownList Then
'End If
'If TypeOf frmCtrl Is CheckBox Then
'End If
'If TypeOf frmCtrl Is RadioButton Then
'End If
'If TypeOf frmCtrl Is FileUpload Then
'End If
If TypeOf frmCtrl Is Button Then
'显示“处理中……”div
CType(frmCtrl, Button).OnClientClick = "coverLayer.on();"
End If
If TypeOf frmCtrl Is LinkButton Then
'显示“处理中……”div
CType(frmCtrl, LinkButton).OnClientClick = "coverLayer.on();"
End If
If frmCtrl.HasControls Then
LoopingControlsShowDiv(frmCtrl)
End If
Next
End Sub

3.调用方法

例:删除按钮调用

'是否删除?
btnDelete.Attributes.Add("onclick", "javascript:if(!confirm('是否删除?')){coverLayer.off();return false;}else{return true;};")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: