请问一下怎么在新页里打开啊
页面1代码如下:
%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Test </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
The WebSite is for test. <br />
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "Button " /> </div>
</form>
</body>
</html>
页面2代码如下:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string url = "Default2.aspx?name= " + TextBox1.Text;
Response.Redirect(url, true);
}
}
我的问题是这样的:比如说我现在就只开了一个IE来打开页面1,然后我输入点内容,点按钮后,页面2还是在当前这个IE窗口中显示内容。
我想要当在页面点击按钮以后,页面2会新开一个IE窗口来显示内容。
请问如何写呢?
------解决方案--------------------string url = "Default2.aspx?name= " + TextBox1.Text;
Response.Redirect(url, true);
Response.Write( " <script> window.open( ' " + url + " ') </script> ");
改成:
string url = "Default2.aspx?name= " + TextBox1.Text;
Response.Write( " <script> window.open( ' " + url + " ') </script> ");