View Full Version : How to pass data from parent window to popup window ?

04-23-2008, 02:25 PM
Hiii All,

Can anybody tell me how data can be passed from parent window to popup window
I have used window.open function and opened 1 page . I am getting data from popup window to text field in parent window.
Now I want to display the data from textfield in popup window on a button click.
Is it possible????

Thanxxx in advance....

04-23-2008, 03:58 PM
If I understand you correctly, you have a parent window with a textfield and a popup with a textfield and you want to get text from the parent window textfield to the popup window textfield.

in the head:

<script type="text/javascript">
function init()
popupWin = window.open('','popupWin','');
popupWin.document.writeln('<html><head><title>test</title></head><body><form><input type="text" id="popupTextBox"/></form></body></html>');
popupText = popupWin.document.getElementById("popupTextBox");
parentText = document.getElementById("parentTextBox");
function transferText()
popupText.value = parentText.value

in the body:

<input type="text" id="parentTextBox"/>
<input type="button" onclick="transferText();"/>

hope it helps.

04-24-2008, 07:11 AM
Thanks Stooshie for giving the code.
I have one more question,I hope you will help me out in that too :)
I have used following code :
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function init()
popupWin = window.open('WebForm6.aspx','popupWin','width=610,height=400');
popupText = popupWin.document.getElementById("FreeTextBox1");
parentText = document.getElementById("parentTextBox");
popupText.value = parentText.value
<body MS_POSITIONING="GridLayout" >
<form id="Form1" method="post" runat="server">
<input type="text" id="parentTextBox"> <input type="button" onclick="init();">

Now in above code I have given path of WebForm6.aspx in popup window i.e in window.open

I am using FreeTextBox control in WebForm6.aspx which have id as FreeTextBox1
Now when button is clicked , I am getting an error as:
Microsoft JScript runtime error: 'popupText' is null or not an object
How this can be solved?

Thnxx Once Again.........

04-25-2008, 05:20 AM
I have done it using Query String.......