RadWindow dynamically added to RadWindowManager not availabe after partial post back

2 posts, 0 answers
  1. shadow
    shadow avatar
    58 posts
    Member since:
    Jun 2008

    Posted 20 Sep 2013 Link to this post


    On my page I am adding the RadWindow and RadWindowManager dynamically. I have a rad ajax panel and a placeholder in rad ajax panel. Then the window and manager are added to the placeholder. I am opening the window with the following java script.
    function OpenEditWindow(managerName, windowName) {
            var WinManager = $find(managerName);
            console.debug("ImageGallery: Opening edit window");
            var windows = WinManager.get_windows();
            for (var i = 0; i < windows.length; i++) {
                console.debug(windows[i].get_name() + ": " + windows[i].get_navigateUrl());
            var oWnd = WinManager.getWindowByName(windowName);

    It contains some testing code as well.

    It works fine first time but after the partial load of the page with ajax panel when i click the button to open window it is giving the following error.

    Uncaught TypeError: Cannot call method 'show' of null

    After partial loading the manager contains no windows, why!! I am utilizing the OnInit event to add the window and manager to the page.
  2. Marin Bratanov
    Marin Bratanov avatar
    5440 posts

    Posted 24 Sep 2013 Link to this post


    It seems you do not recreate the controls properly or you have disabled the ViewState for the manager which would prevent it from maintaining its controls collection. Also note that you need to make sure to set the same IDs to dynamically created controls.

    What I would advise, however, is the following:
    - examine this sticky thread on opening a RadWindow from the server: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.
    - add a RadWindowManager in the page markup and avoid creating it dynamically. Keep it out of any update panels or AJAX settings to prevent it from disposing
    - open your RadWindows with JavaScript alone, the radopen() global function or the open() method of the manager can create a brand new instance in the browser without a postback: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html.

    It seems in your case either the script is called too early (i.e. you do not utilize the Sys.Application.Load event), or the controls are not recreated properly. Going with the JS approach should resolve both.

    Marin Bratanov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top