Ana sayfamızın html kodları aşağıdaki gibidir ;
<%@ 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>Untitled Page</title>
<script language="javascript" type="text/javascript">
function openWindow()
{
window.open('testpage.aspx', null, 'height=200,width=400,status=yes,toolbar=no,menubar=no,location=no');return false;
}
</script></
head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" runat="server" onclick="openWindow();" value="Click Me" />
<b>Information from the popup window :</b>
<br />
<label>
UserName :
</label>
<label id="lblUName">
</label>
<br />
<label>
Address :
</label>
<label id="lblAddress">
</label>
<br />
<label>
Phone no :
</label>
<label id="lblPhone">
</label>
</div>
</form>
</body>
</html>
Pop-Up penceresinin html kodları :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testpage.aspx.cs" Inherits="testpage" %>
<!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>Untitled Page</title>
<script language="javascript" type="text/javascript">
function passValues()
{
window.opener.document.getElementById('lblUName').innerText = document.getElementById('txtUName').value;
window.opener.document.getElementById('lblAddress').innerText = document.getElementById('txtAddress').value;window.opener.document.getElementById(
'lblPhone').innerText = document.getElementById('txtPhone').value;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<label>
UserName :
</label>
<input type="text" id="txtUName" />
<br />
<label>
Address :
</label>
<input type="text" id="txtAddress" />
<br />
<label>
Phone No. :
</label>
<input type="text" id="txtPhone" />
<br />
<input type="submit" onclick="passValues(); window.close()" value="Submit" />
</div>
</form>
</body>
</html>
Pop-up penceresinde değerleri taşıyacak olan javascript metodunun içini aşağıdaki gibi dolduralım;
function passValues()
{
window.opener.document.getElementById('lblUName').innerText = document.getElementById('txtUName').value;
window.opener.document.getElementById('lblAddress').innerText = document.getElementById('txtAddress').value;window.opener.document.getElementById(
'lblPhone').innerText = document.getElementById('txtPhone').value;
}