[英]open asp.net page in new window
I'm trying to open asp.net page in new window while loading itself. 我正在尝试在加载自己的同时在新窗口中打开asp.net页面。 I tried with the following code.
我尝试使用以下代码。 But it is opening in the same window not in the new window.
但是它在同一窗口中打开而不是在新窗口中打开。
protected void Page_Load(object sender, EventArgs e)
{
if (HttpContext.Current.Request.UserAgent != null)
{
var userAgent = HttpContext.Current.Request.UserAgent.ToLower();
if (userAgent.Contains("iphone;"))
{
// iPhone
Form.Target = "_blank";
}
}
}
Any help is appreciated. 任何帮助表示赞赏。 thanks !!
谢谢 !!
Use a Javascript in code behind to redirect : 在后面的代码中使用Javascript来重定向:
Response.Write("<script>window.open('http://www.google.com.hk/','_blank');</script>");
Or use ScriptManager and you can pass parameters too: 或者使用ScriptManager ,您也可以传递参数:
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('YourPage.aspx?Param=" + ParamX.ToString() + "');",true);
Or if you have a button you can use it as below: 或者如果你有一个按钮,你可以使用它如下:
Button1.OnClientClick="javascript:window.open('YourPage.aspx?Param=" + ParamX.ToString() + "');";
这就是我所做的,试试吧
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('ViewDetails.aspx','mywindow','menubar=1,resizable=1,width=900,height=600');", true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.