locked
Unable to pass value in window.showModalDialog RRS feed

  • Question

  • I have been working with  window.showModalDialog  to show custom aspx page on click on button in CRM 2011 and passing sharedObject  to ModalDilog, But when I try to get sharedObject   at ModalDilog I am getting undefined.

    any suggestions,help...

    code for Parent page

    function ShowModal () {
     var formule = document.getElementById ("conditiondetails");


                var sharedObject = {};
                sharedObject.formule = formule.value;


                if (window.showModalDialog) {
                    var retValue = showModalDialog ("http://uvo1jn2qrsoxiamwd5x.vm.cld.sr:8080/GhatanaPluginConfiguration.aspx", sharedObject, "dialogWidth:200px; dialogHeight:200px; dialogLeft:300px;");
                    if (retValue) {
                        UpdateFields (retValue.formule);
                    }
                }
                else {
                        // for similar functionality in Opera, but it's not modal!
                    var modal = window.open ("http://uvo1jn2qrsoxiamwd5x.vm.cld.sr:8080/GhatanaPluginConfiguration.aspx", null, "width=300,height=300,left=300,modal=yes,alwaysRaised=yes", null);
                    modal.dialogArguments = sharedObject;
                }
            }

    code for Child page

    <script type="text/javascript">
             function Init() {
                 var sharedObject = window.dialogArguments;

                 var formule = document.getElementById("TextBox1");

                 formule.value = sharedObject.formule;

             }

             function OnOK() {
                 var formule = document.getElementById("TextBox1");


                 if (window.showModalDialog) {
                     var sharedObject = {};
                     sharedObject.formule = formule.value;


                     window.returnValue = sharedObject;
                 }
                 else {
                     // if not modal, we cannot use the returnValue property, we need to update the opener window
                     window.opener.UpdateFields(formule.value);
                 }
                 window.close();
             }

             function OnCancel() {
                 window.close();
             }
        </script>

                                        

    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.

    Thursday, June 20, 2013 12:45 PM

All replies

  • You should be able to create a global var on your calling page for your shared object, then refer to it from your dialog using something like window.parent.sharedObject.
    Thursday, June 20, 2013 1:35 PM
  • this code works perfectly when I use plain htm pages for parent as well as child.

    The problem arises when I use MS CRM out of box form and asp.net page as parent and child.

    This is possibly a cross domain issue. 

    will there be any change to handle this crossdomain issue.


    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.

    Thursday, June 20, 2013 2:13 PM