C# 跳转新页面
C# 跳转新页面
string url = "http://www.vipsoft.com.cn"; ResponseRedirect.Redirect(Response, url, "_blank", "'toolbar=0,scrollbars=1,status=0,menubar=0,resizable=1,top=0,left=0,height=800,width=1000");}
调用下面代码
public class ResponseRedirect { public static void Redirect(HttpResponse response, string url, string target, string windowFeatures) { if ((String.IsNullOrEmpty(target) || target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && String.IsNullOrEmpty(windowFeatures)) { response.Redirect(url); } else { Page page = (Page)HttpContext.Current.Handler; if (page == null) { throw new InvalidOperationException("Cannot redirect to new window ."); } url = page.ResolveClientUrl(url); string script; if (!String.IsNullOrEmpty(windowFeatures)) { script = @"window.open(""{0}"", ""{1}"", ""{2}"");"; } else { script = @"window.open(""{0}"", ""{1}"");"; } script = String.Format(script, url, target, windowFeatures); ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true); } } }
本文来自博客园,作者:VipSoft 转载请注明原文链接:https://www.cnblogs.com/vipsoft/p/3627683.html