Find control inside window from parent window

3 posts, 1 answers
  1. Dmitry
    Dmitry avatar
    121 posts
    Member since:
    Jul 2010

    Posted 31 Aug 2011 Link to this post

    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. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    4609 posts

    Posted 01 Sep 2011 Link to this post

    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 >>

  3. Dmitry
    Dmitry avatar
    121 posts
    Member since:
    Jul 2010

    Posted 02 Sep 2011 Link to this post

    Everything works just fine! Thank you very much.
Back to Top