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

RadWindow dynamically added to RadWindowManager not availabe after partial post back

1 Answer 30 Views
Window
This is a migrated thread and some comments may be shown as answers.
shadow
Top achievements
Rank 2
shadow asked on 20 Sep 2013, 12:41 PM
Hello,

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");
        console.debug(WinManager);
      
        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);
        oWnd.show();
}

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.

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 24 Sep 2013, 01:20 PM
Hi,

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.


Regards,
Marin Bratanov
Telerik
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.
Tags
Window
Asked by
shadow
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or