RadAjaxManager with multiple RadWindows

2 posts, 0 answers
  1. Graham
    Graham avatar
    7 posts
    Member since:
    Feb 2008

    Posted 05 Feb 2010 Link to this post

    Hi

    I have a content page (main.aspx) which launches rad windows through a RadWindowManager.  Each of these child windows can also launch "grandchild" RadWindows, but by using the RadWindowManager on the parent page.  This is essential as I want each "grandchild" window to be freely moveable outside the bounds of the child window.

    The content of each RadWindow is a separate .ASPX page which runs from a Master Page.  This MasterPage has its own RadAjaxManager and the window content page has a RadAjaxManagerProxy. 

    The parent page and the child windows have RadGrids, and I want to rebind these when the "grandchild" editing window is closed. A typical sequence might involved:

    1. Button clicked on main.aspx to launch child.aspx in window
    2. Button clicked on child.aspx to launch grandchild.aspx in window
    3. Data edited on grandchild.aspx and grandchild.aspx closed
    4. Grid in child.aspx rebound when grandchild.aspx is closed.
    5. Data edited in child.aspx and child.aspx closed.
    6. Data grid in main.aspx rebound.

    Rebinding is done using the OnClientClose JavaScript method and a RadAjaxManager. Essentially, the jS method generates a Ajax Request which is handled in a code-behind handler function which performs the  necessary rebinding. 

    Here is the problem - the OnClientClose JS function MUST be on the main.aspx as this is where the RadWindowManager is.  Whenever the child.aspx windows or grandchild.aspx windows are closed, this OnClientClose function fires as expected - BUT the AjaxRequest is ALWAYS handled by main.aspx - this is presumably because the RadAjaxManager.GetCurrent(Page) method always returns the manager on the main.aspx page.

    function Window_OnClientClose(oWnd, eventArgs) {  
     
                var Rebind = oWnd.get_contentFrame().contentWindow.GetRefreshValue();  
                var Argument = oWnd.get_contentFrame().contentWindow.GetArgumentValue();  
     
                if (typeof (Rebind) !== 'undefined' && Rebind != null) {  
                    if (Rebind == "True") {  
                        var AjaxManager = $find("<%=RadAjaxManager.GetCurrent(Page).ClientID %>");  
                        if (AjaxManager) {  
                            AjaxManager.ajaxRequest(Argument);  
                        }  
                    }  
                }  
            } 

    The Rebind and Argument variables above are for dealing with the rebinding and not important to the basic functionality.  I am using code similar to this on the main.aspx page and in the child windows for dealing with the AjaxRequest:

            Public Sub Page_Load(ByVal Sender As ObjectByVal e As EventArgs) Handles MyBase.Load  
     
                Dim Manager As RadAjaxManager = RadAjaxManager.GetCurrent(Page)  
                AddHandler Manager.AjaxRequest, AddressOf AjaxManager_AjaxRequest  
     
            End Sub 

    Protected Sub AjaxManager_AjaxRequest(ByVal sender As ObjectByVal e As AjaxRequestEventArgs)  
     
                Select Case e.Argument.ToString  
     
                    Case "Product" 
                        ProductsGrid.Rebind()  
     
                End Select 
     
            End Sub 


    If a window has a radgrid that needs to be rebound (or any other action when its child window is closed), then I need to be able to handle an AjaxRequest on this page that is generated from the main.aspx in the window, NOT on the main.aspx page.

    Essentially, I need to be able to reference the RadAjaxManager in the child windows from the main page

    How can I do this?

  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 10 Feb 2010 Link to this post

    Hello Graham,

    I am afraid that it is not possible to access one page RadAjaxManager from another page. The same it true for any controls on a page. For instance you cannot get reference to a RadGrid defined in the child.aspx in the main.aspx.
    However, in order to overcome this issue, I would suggest you to handle the particular window close in the page you need to update. I assume that the window is closed on a button click. In this case you can call a method defined in its parent to invoking ajax request there.

    I hope this helps.

    All the best,
    Iana
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top