Moving value from popup Webform to main Webform?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I transfer some text from a Textbox in a popup window to the main
webform that opened that popup?
The popup webform will have some type of Button that the user will click in
order to accept those changes. This is where the transter of the value should
be. It could also be done when I close the popup form (whichever is easier).
Once the popup form is closed, the value will then be used to fill a textbox
in the main Form.
I use VS2005 v2.0.

Thanks.
 
1. pass a text box name (client-side name) from the main form to the
popup form (in the url).
2. the popup form gets a reference to it's "opener." Search for
window.opener in google. Note: getting a reference to the opener
could vary depending on browser type and the way the window is opened.
See also showModalDialog.

Example:
<script type="text/javascript">
var OpenerWindow = window.opener; // for when using window.open
if (OpenerWindow == null) {
OpenerWindow = window.dialogArguments; // for when using
window.openModalDialog
}
</script>

3. the popup form sets the text box in the parent form to a value
window.opener.textboxname.value = 'hello';
a) You can build this string dynamically in the code-behind - string
together the command with the proper text box name.
b) You can build this string dynamically in javascript using the
javascript eval( ) command: eval( 'window.opener.' + textboxname +
'.value') = 'hello'. Not sure on the syntax here, but it's something
like that.
 
Back
Top