This exercise requires no C# or VB.Net code at all (unless you want to start getting fancy), and is relatively well documented on the internet. However, I like to recap things quickly through these little tutorials, so hopefully this might summarize how to quickly get up and running with parent<->child window script communication.
First, create two web forms (they don't need to be, but for our exercise they will be). We'll call the Default.aspx and Default2.aspx.
Second, open up Default.aspx and add the following script functionality:
<input id="Button1" type="button" value="button" onclick="window.open('default2.aspx');" />
<input id="Text_Value" type="text" />
...here you see that you open up default2.aspx when you click on the button.
Third, go to your Default2.aspx file and add the following HTML:
Please Enter Some Data:
<input id="Text1" type="text" />
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" /></div>
Fourth...add the following script:
function Button1_onclick() {
opener.document.getElementById('Text_Value').innerText =
document.getElementById('Text1').value;
self.close();
return;
}
The result will be opening up the default2.aspx form from default.aspx, you can enter text into the Text1 field (see above), click the Button1 which calls the Button1_onclick method. This method communicates with the parent window, sets a text box in that window's document and closes itself.
This requries no .Net code to accomplish; this can all be done through JavaScript.
Recommended reading:




