在新窗口中打开asp.net页面

dot*_*cks 4 c# asp.net mobile-safari

我正在尝试在加载自己的同时在新窗口中打开asp.net页面.我尝试使用以下代码.但是它在同一窗口中打开而不是在新窗口中打开.

     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";

            }


        }
    }
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏.谢谢 !!

Zak*_*aki 10

在后面的代码中使用Javascript来重定向:

Response.Write("<script>window.open('http://www.google.com.hk/','_blank');</script>");
Run Code Online (Sandbox Code Playgroud)

或者使用ScriptManager,您也可以传递参数:

 ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('YourPage.aspx?Param=" + ParamX.ToString() + "');",true);
Run Code Online (Sandbox Code Playgroud)

或者如果你有一个按钮,你可以使用它如下:

Button1.OnClientClick="javascript:window.open('YourPage.aspx?Param=" + ParamX.ToString() + "');";
Run Code Online (Sandbox Code Playgroud)