使用Redirect打开新窗口
方法一:
/// <summary>
/// 使用此方法,可以确保同一个窗口只打开一次
/// </summary>
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.btnRedirect.Attributes.Add("onclick", "this.form.target='_newName'");
}
protected void btnRedirect_Click(object sender, EventArgs e)
{
//this.form1.Target = "_blank";
Response.Redirect("NewPage.aspx");
}
}
方法二:
/// <summary>
/// 使用此方法,没点击一次就会打开一个窗口
/// </summary>
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.form1.Target = "_blank";
}
protected void btnRedirect_Click(object sender, EventArgs e)
{
Response.Redirect("NewPage.aspx");
}
}