father.aspx
<head runat="server">
<title></title>
<script type="text/javascript">
//---------------------------------------------------
function OpenWindow() {
window.open("child.aspx");
}
function setValue(m) {
document.getElementById("txt_Value").value = m;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" name="txt_Value" id="txt_Value" runat="server" />
<input type="button" name="btn_ShowClose" id="btn_ShowClose" value="按钮" onclick="OpenWindow();" />
<br />
<asp:HiddenField ID="HiddenField1" runat="server" />
</div>
</form>
</body>
</html>
father.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("adf" + HiddenField1.Value);
}
--------------------------------
child.aspx
<title></title>
<script type="text/javascript">
function CloseWind() {
opener.setValue("2");
window.opener.document.forms(0).submit();
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="CloseWind()"/>
</form>
</body>
child.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
else
{
Response.Write("<script>");
Response.Write("function fm_send()");
Response.Write("{");
Response.Write("window.opener.document.getElementById('HiddenField1').value =1;");
Response.Write("window.opener.document.forms(0).submit();");
Response.Write("window.close()");
Response.Write("}");
Response.Write("fm_send()");
Response.Write("</script>");
}
}