ASP.NET,Javascript,Ajax: How to get a string from window.showModalDialog

Hi there,
I would like to know how I can get a string from a modal dialog and use it on the parent form using window.showModalDialog
LVL 4
karakavAsked:
Who is Participating?
 
P_RamprathapCommented:
When you call showModalDialog you do this:
var oReturnValue = showModalDialog(....);
Within showModalDialog, assuming your textboxes have IDs of "txtForename" and "txtSurname":
<body onbeforeunload="terminate();">
function terminate()
{
  var o = new Object();
  o.forename = document.getElementById("txtForename").value;
  o.surname = document.getElementById("txtSurname").value;
  window.returnValue = o;
}


Ram
0
 
vinodsnair2001Commented:
you can call the modal dialog page as
var retVal = window.showModalDialog("ShowMailDetail.aspx

and in the modal dialog before closing the window you have to set
returnValue = "your return string should be specified here";
0
 
ajitha75Commented:
use window.returnValue in the document loaded in showModalDialog window. That can be accessed as a return value of the method call like below

var returnData = window.showModalDialog("test.html");

Thanks
Ajitha
0
 
karakavAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.