首页 > 编程语言 >C# 跳转新页面

C# 跳转新页面

时间:2022-12-23 10:05:43浏览次数:48  
标签:Redirect string script C# 新页面 url 跳转 target String


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);
}
}
}

 

标签:Redirect,string,script,C#,新页面,url,跳转,target,String
From: https://blog.51cto.com/u_15116285/5964870

相关文章