Default1.aspx 内容
--------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="openWindow_Default1" %>
<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>
</form>
</body>
</html>
--------------------------------------------------------------------------------
Default1.aspx 代码
--------------------------------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class openWindow_Default1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string openNew = "javascript:window.open('Default2.aspx','查找','height=250,width=550,top='+(screen.availHeight-250)/2+',left='+(screen.availWidth-550)/2+',toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=yes');return false;";
Button1.Attributes.Add("onclick", openNew);
}
}
--------------------------------------------------------------------------------
Default2.aspx 内容
--------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="openWindow_Default1" %>
<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</body>
</html>
--------------------------------------------------------------------------------
Default2.aspx 代码
--------------------------------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class openWindow_Default1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
// 向父页面提交内容
this.Response.Write("<script language='javascript'>window.opener.parent.frames['form1'].document.all.TextBox1.value='" + TextBox1.Text + "';</script>");
this.Response.Write("<script language='javascript'>window.opener.parent.frames['form1'].document.form1.submit();window.close();</script>");
}
}