This is a migrated thread and some comments may be shown as answers.

Find control inside window from parent window

2 Answers 196 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 31 Aug 2011, 10:16 AM
Hello,
I have a page, which opens a dialog window (Window1). In Window1 there's a custom AJAX control with button which in turn opens new dialog window (Window2). When Window2 closes, a page must handle Window2's OnClientClose event, and Window2 must pass some data to my custom control on WIndow1. To avoid stack overflow, as you adviced here, I put handler on main page.
And now I want to get data sent by Window2 and put them to my control on Window1. This is how I'm doing that now:

 function referenceWindowClose(sender, args) {
            sender.remove_close(referenceWindowClose);
            var arg = args.get_argument();
            if (!arg) return;
            var ctl = $find(arg.TargetControlID);
            if (ctl == nullreturn;
            ctl.set_text(arg.Caption);
            ctl.set_value(arg.RefID);
        }
Variable named ctl is my custom AJAX control. Problem is ctl is always null. I know this happens because Window1 is in IFRAME. But how do I find it from main page? Using sender parameter? Please help.

2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 01 Sep 2011, 02:44 PM
Hi Dmitry,

You would first need to access the iframe of Window1. This can be done by getting a reference to this first RadWindow and calling a function that is declared in its content page, which populates the desired value. You can pass the custom argument as a parameter in these functions. I.e. the following bit should be in the page, loaded within RadWindow1:
function populateValue(arg)
{
    var ctl = $find(arg.TargetControlID); 
    if (ctl == null) return
    ctl.set_text(arg.Caption); 
    ctl.set_value(arg.RefID);
}

and on the main page you should call it in a similar way:
if (!arg)
{
     return;
}
else
{
    var oWnd = GetRadWindowManager().getWindowByName("RadWindow1");
    oWnd.get_contentFrame().contentWindow.populateValue(arg);
}


How to call a function from another RadWindow is explained here.


Best wishes,
Marin
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Dmitry
Top achievements
Rank 1
answered on 02 Sep 2011, 10:05 AM
Everything works just fine! Thank you very much.
Tags
Window
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Dmitry
Top achievements
Rank 1
Share this question
or