I'm trying to open asp.net page in new window while loading itself. 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 :
Response.Write("<script>window.open('http://www.google.com.hk/','_blank');</script>");
Or use ScriptManager and you can pass parameters too:
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() + "');";
this is what i done, just try this
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('ViewDetails.aspx','mywindow','menubar=1,resizable=1,width=900,height=600');", true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With