C# 如何在点击按钮时弹出页面?
我想在我的应用程序主页上弹出一个新页面。位置必须在中间,不能太大,不应在主页中作为新选项卡打开,带有关闭、最小化/混合化选项的栏不应存在 这是我的密码:C# 如何在点击按钮时弹出页面?,c#,asp.net,C#,Asp.net,我想在我的应用程序主页上弹出一个新页面。位置必须在中间,不能太大,不应在主页中作为新选项卡打开,带有关闭、最小化/混合化选项的栏不应存在 这是我的密码: protected void Page_Load(object sender, EventArgs e) { HyperLink1.Attributes.Add("onclick", "window.open('WebForm1.aspx',null,'height=350, width=250,sta
protected void Page_Load(object sender, EventArgs e)
{
HyperLink1.Attributes.Add("onclick", "window.open('WebForm1.aspx',null,'height=350, width=250,status= no, resizable= no, scrollbars=no, toolbar=no,location=center,menubar=no')");
}
但是
- 它是可设置的,位置不在页面中央
- 页面在主页面中打开,但作为新选项卡打开
- 我不知道如何删除酒吧:关闭,最大化,最小化
protected void Page_Load(object sender, EventArgs e)
{
HyperLink1.Attributes.Add("onclick", "centeredPopup('WebForm1.aspx','myWindow','500','300','yes');return false");
}
<script language="javascript">
var popupWindow = null;
function centeredPopup(url,winName,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
popupWindow = window.open(url,winName,settings)
}
</script>
受保护的无效页面加载(对象发送方,事件参数e)
{
添加(“onclick”、“centeredpoop('WebForm1.aspx'、'myWindow'、'500'、'300'、'yes');返回false);
}
var popupWindow=null;
功能中心弹出窗口(url、winName、w、h、滚动){
LeftPosition=(屏幕宽度)?(屏幕宽度-w)/2:0;
顶部位置=(屏幕高度)?(屏幕高度-h)/2:0;
背景=
'高度='+h+',宽度='+w+',顶部='+TopPosition+',左侧='+LeftPosition+',滚动条='+scroll+',可调整大小'
popupWindow=window.open(url、winName、设置)
}
我认为您无法控制浏览器是将其作为选项卡打开还是作为新窗口打开。你也不应该。这由浏览器和最终用户决定。已经回答了这个问题-实际上,David是对的。请检查此[链接]