假设在Default.aspx中打开Dialog.aspx,则两个页面的HTML代码如下:
Default.aspx:
<%@ Page language="c#" Codebehind="Dialog.aspx.cs" AutoEventWireup="false" Inherits="MyProject.Dialog" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<FONT face="宋体">
<form id="Form1" method="post" runat="server">
<P><a οnclick="window.open('Dialog.aspx','NewWindow','left=300,top=200,height=260,width=350,scrollbars=no,resizable=no')" href="#">点我</a></P>
</form>
</FONT>
</body>
</HTML>
Dialog.aspx:
<%@ Page language="c#" Codebehind="Dialog.aspx.cs" AutoEventWireup="false" Inherits="MyProject.Dialog" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Dialog</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function RefreshOpener
{
opener.window.location.reload();
}
</script>
</HEAD>
<body οnunlοad="RefreshOpener();">
<form id="Form1" method="post" runat="server">
<INPUT type="button" value="Button" οnclick="window.close();">
</form>
</body>
</HTML>