简体   繁体   English

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

[英]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.

相关问题 asp.net在新窗口中打开超链接字段 - asp.net open hyperlinkfield in new window asp.net:如何使用c#在新窗口(不是标签页或当前页面)中打开新的asp.net页 - asp.net: How to open a new asp.net page in new window (not tab or current page) using c# 如何打开从Iframe重定向的页面,以在ASP.NET的父窗口中作为新标签打开? - How to open the redirected page from Iframe to open as a new tab in the parent window in ASP.NET? 使用 ASP.NET 按钮、C# 和页面背后的代码在新选项卡中打开窗口 - Open Window in new tab using an ASP.NET Button, C#, and the code behind the page 如何在ASP.NET C#中的新选项卡(NOT WINDOW)中打开页面? - How to open page in new Tab (NOT WINDOW) in ASP.NET C#? 如何在asp.net中打开新窗口并禁用旧窗口? - How to open new window in asp.net and disable the old one? Asp.net MVC如何从控制器打开新窗口 - Asp.net MVC How To Open New Window From Controller GridView中的按钮可在新窗口中打开(ASP.Net 3.5) - Button in a GridView to open in a new Window(ASP.Net 3.5) asp.net按钮类型链接应在新窗口中打开 - asp.net Button type link should open on new window 在新浏览器中打开 PDF 文件 ASP.NET Core 3 中的 window - Open PDF file in new browser window in ASP.NET Core 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM