Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
All I am calling Window.ShowModalDialog() from my asp.net application. My browser version is IE7
and my Modal popup come from another server, there IE version is IE9. I am not getting return values from the modal popup window.

while exit from modal popup window i am using the below code.
JavaScript
var MyArgs = {a,b,c};
window.returnvalue = true;
window.returnValue = MyArgs;
window.close();


In local application i am using this code
JavaScript
var MyArgs = window.showModalDialog(url + "?a=" + a, MyArgs, 'dialogHeight:450px; dialogWidth: 750px; center: Yes; resizable: Yes; status: No;', "true");

if(MyArgs.String.length>1)
{
//here i am getting error (MyArgs is undefinied.
}

Plese help me.Thanks in advance
Posted
Updated 15-Oct-13 2:51am
v2

1 solution

Hello Murthy,

This is a known problem in showModalDialog. See following links.

If you really want to return an array and access it I suggest you clone it as shown below or use a string as return value.
JavaScript
// In the calling page (TestDialog.htm)
function cloneArray(ary) {
    var i;
    var newAry = [];
    for (i = 0; i < ary.length; i++){
        if (Object.prototype.toString.call(ary[i]) == '[object Array]') {
            newAry.push(cloneArray(ary[i]));
        } else {
            newAry.push(ary[i]);
        }
    }
    return newAry;
}

// This function open a dialog and reads the return value and displays it,
function fnOpen() {
    var sFeatures = fnSetValues();
    window.returnValue = undefined;
    var retVal = window.showModalDialog("http://localhost:8080/myapp/dialog.htm", "", sFeatures)
    alert(cloneArray(retVal));
}

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900