Some times we are opening pages in new window by using javascript when we click on links. in this case some times we have to get the data(values) from parent window. this is posible by javascript.
parent window code
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
<title>Untitled Page</title>
<script type=”text/javascript” language=”javascript”>
function openWindow()
{
window.open(‘child.aspx’,'Preview’,’scrollbars=yes,toolbar=no,width=50,height=50,top=40,left=40′);
}
</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox><br />
<asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox>
<br />
<input id=”Button1″ type=”button” value=”preview” onclick=”openWindow();” />
</div>
</form>
</body>
</html>
Child window code
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
<title>Untitled Page</title>
<script type=”text/javascript” language=”javascript”>
function displayValues()
{
document.getElementById(‘Label1′).innerText = window.opener.document.form1.TextBox1.value;
document.getElementById(‘Label2′).innerText = window.opener.document.form1.TextBox2.value;
}
</script>
</head>
<body onload=”displayValues();”>
<form id=”form1″ runat=”server”>
<div>
<asp:Label ID=”Label1″ runat=”server” Text=”Label”></asp:Label><br />
<asp:Label ID=”Label2″ runat=”server” Text=”Label”></asp:Label>
</div>
</form>
</body>
</html>
I used this code to show preview of the submited data.