???????????????????????????
??? ???????????????????????在页面中用到弹出新页面的情况比較多的,一般来说都是使用JS方法
showModalDialog("新页面相对路径+?
???????????????????showModalDialog("新页面相对路径+?
參数1&參数2",window,"新页面样式");然后会新弹出一个模态的page页。
而在有些时候,不过显示一些单一的、少量的数据,或者一些简单的操作时。
就不是必需使用新弹出页面了。
此时,最好使用弹出层。也就是数据还是显示在当前页面的某个控件上,然后通过JS方法实现达到弹出的目的。
看以下的样例:
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> ???<title></title></head><body> ???<form id="form1" runat="server"> ???<div> ????<ul> ?????<li>操作一</li> ?????<li>操作二</li> ?????<li><asp:Button ID="btnShow" runat="server" Text="操作三(弹出层)" OnClientClick="return ShowBlock();" /></li> ?????<li>操作四</li> ?????<li>操作五</li> ????</ul> ???</div> ???<!--弹出层,--> ??????<div id="divNewBlock" style=" border:solid 5px;padding:10px;width:600px;z-index:1001; ????????position: absolute; display:none;top:50%; left:10%;margin:-50px;"> ???????????<div style="padding:3px 15px 3px 15px;text-align:left;vertical-align:middle;" > ???????????????<div> ??????????????????弹出层,平时在隐藏状态,这里能够放控件,载入数据。操作数据等。 ???????????????</div> ???????????????<div> ????????????????????????<asp:Button ID="BtnOperation" runat="server" Text="操作button" OnClientClick="return Operate();"/> ????????????????????????????????????????<asp:Button ID="BttCancel" ?runat="server" Text="关闭" OnClientClick="return HideBlock();" /> ???????????????</div> ???????????</div> ?????</div> ????</form></body><script type="text/javascript" language="javascript"> ???function HideBlock() { ???????document.getElementById("divNewBlock").style.display = "none"; ???????return false; ???} ???function ShowBlock() { ???????var set = SetBlock(); ???????document.getElementById("divNewBlock").style.display = ""; ???????return false; ???} ???function SetBlock() { ???????var top = document.body.scrollTop; ???????var left = document.body.scrollLeft; ???????var height = document.body.clientHeight; ???????var width = document.body.clientWidth; ???????if (top == 0 && left == 0 && height == 0 && width == 0) { ???????????top = document.documentElement.scrollTop; ???????????left = document.documentElement.scrollLeft; ???????????height = document.documentElement.clientHeight; ???????????width = document.documentElement.clientWidth; ???????} ???????return { top: top, left: left, height: height, width: width }; ???} ???function Operate() { ???????return false; ???} ???</script></html>
效果例如以下:
事实上是非常easy的控制,这样一来载入数据和操作等都在当前页面,对于要求不是非常多的操作就方便了很多。
代码下载:http://download.csdn.net/detail/yysyangyangyangshan/7734257 ???????????????ASP.NET—013:实现带控件的弹出层(弹出框)
原文地址:https://www.cnblogs.com/llguanli/p/8443315.html