Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在点击按钮时弹出页面?_C#_Asp.net - Fatal编程技术网

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是对的。请检查此[链接]