views:

50

answers:

2

I have an asp.net page. I'm using a jquery library to open a modal window on link click. Within this modal window I'm loading another page. After i make update within this modal window I need to send a callback to "Parent" page. if I call function from this window I'm getting the error it couldn't find function. Window.opener.functionname also not working.

here is an example of my code

$(function () {
            $('#ControlId').click(function (e) {
                e.preventDefault();

                $.ModalWindow({
                    bgColor: '#3333cc',
                    url: 'default.aspx'
                });

                return false;
            });  

                return false;
            });
        });

Is there any way how to send a callback?

A: 

You can call any JavaScript that lives in the parent window as long as the domain is the same.

Place some javascript code like this in your parent page:

function handleChild(){
    // put your callback code here
    $.nyroModalRemove(); // if you want your child to remove the popup
}

Place some javascript code like this in your child page (the one popped up):

function callParent(){
    if ((window.parent) && (window.parent != window)) {
        if (window.parent.handleChild) {
            window.parent.handleChild();
        }
    }
}

and call it via a button <input type='button' onclick='callParent()'>click me to close</input> or via the onload of your page $(document).ready(function(){callParent();});

Pete Amundson
Hi Pete thank you for quick response can you tell me please in more detail how is the code which I need to place to child page works? Its highlighting window and I'm not how to reference parent page. Thank you in advance
GEka
Its a nyromodel library
GEka
Thank you I'm able to call parent page this way, but I after I open the window javascript function give me response and I'm getting the message below "the target couldn't be found or did not emplement ICallbackEventHandler"
GEka
Sounds like a different issue. Is this a response you get after calling back to the server. What are you doing to inside the `handleChild` parent function?
Pete Amundson
Yes, I'm trying to perform calback within devexpress callback panel. If I initiate callback before I open modal window it works fine. if I call from modal window it calls javascript function in parent page but give me also error that couldnot find panel (the target couldn't be found or did not emplement ICallbackEventHandler)Pete thank you for your help
GEka
OK, if you manually call the `handleChild` javascript function before opening the modal window it works. But, if you call the `handleChild` function after opening the modal window you get errors. I'm not too familiar with how the Callback panel works in DevExpress (I imagine it is an extension of the UpdatePanel), but it might be that your modal window is moving html elements to a different area of the DOM (very common for popup plugins) and DevExpress is expecting a certain set of elements to exist in order to successfully update.
Pete Amundson
A: 

this must solve your problem

Naresh
that is just another jQuery dialog plugin and doesn't solve the issue of calling back to the parent page
Pete Amundson