Tuesday, May 19, 2009

How to return value from window.showModalDialog to parent window in javascript ?

Here is the example

Function to open dialog window from parent window

function showFleetDialog()
var oReturnValue = window.showModalDialog("/abc/page.aspx", this, "dialogWidth:800px;dialogHeight:500px;resizable:yes;");
if(oReturnValue != null)
document.getElementById('<%= txtFleetNo.ClientID %>').value = oReturnValue.FleetCode;
return false;

Function to retun value from dialog window
function closeThisWindow(fleetCode, fleetId)
var o = new Object();
o.FleetCode = fleetCode;
o.FleetId = fleetId;
window.returnValue = o;


No comments: