csharp 在新选项卡中打开窗口

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 在新选项卡中打开窗口相关的知识,希望对你有一定的参考价值。

var win = window.open("", '_blank');

  win.focus();

 

 

 

/*********************/

HttpContext context = HttpContext.Current; if ((String.IsNullOrEmpty(target) || target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && String.IsNullOrEmpty(windowFeatures)) { context.Response.Redirect(url); }

        else

        {

            Page page = (Page)context.Handler;

            if (page == null)

            {

                throw new InvalidOperationException("Cannot redirect to new window outside Page context.");

            }

 

            if (SessionManager.IsRedirectPrint)

            {

                context.Response.Redirect(url );

                SessionManager.IsRedirectPrint = false;

                return;

            }

 

            url = page.ResolveClientUrl(url);

            string script;

            // setTimeout ( function(){  window.open('../License/AddBuildingLicenseOld.aspx'); } , 1000);

            if (!String.IsNullOrEmpty(windowFeatures))

            {

                script = @"    window.open('{0}', '{1}', '{2}'  );  ";

            }

            else

            {

                script = @"  window.open('{0}', '{1}' ); ";

            }

            script = "setTimeout ( function(){  " + String.Format(script, url, target, windowFeatures) + " } , 1000);";

            ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);

        }

 

 

 

 

public static void OpenPopup(String url)

    {

        HttpContext context = HttpContext.Current;

        string script = "window.open('" + url + "', 'popup_window', 'menubar=no,toolbar=no,fullscreen=no,resizable=yes,scrollbars=yes,directories=no,status=no,help=no');";

        Page page = (Page)context.Handler;

        if (page == null)

        {

            throw new InvalidOperationException("Cannot redirect to new window outside Page context.");

        }

        url = page.ResolveClientUrl(url);

 

        ScriptManager.RegisterStartupScript(page, typeof(Page), "OpenPopup", script, true);

 

    }

以上是关于csharp 在新选项卡中打开窗口的主要内容,如果未能解决你的问题,请参考以下文章