radwindow onclientclose question

2 posts, 0 answers
  1. Steven
    Steven avatar
    32 posts
    Member since:
    Jul 2012

    Posted 20 Jan 2012 Link to this post

    Kinda new to telerik.

    I have a page with a windowmanager, radwindow, and a customcontrol on it.

    the customcontrol uses javascript to open the control on the parent page like so

    function UseRadWindowOnParentPage(DialogURL,RadWindowID, Width, Height, Title, argument) {
        var oManager = GetRadWindowManager();
        var oWnd = oManager.GetWindowByName(RadWindowID);
        oWnd.Show();
        oWnd.SetSize(Width, Height);
        oWnd.SetUrl(DialogURL);
        oWnd.SetTitle(Title);
        oWnd.Center();
        oWnd.argument = argument;
     
        oWnd.OnClientClose = function () {
            alert('client close');
        }
    }

     

     

    oWnd.OnClientClose never fires.
    Any idea whats going on?

    If i set the OnClientClose property in the radwindow control it works. The radwindow is used several times and not everything is supposed to have a onclientclose event.

    I know I could add a radwindow for every popup I need but I got it this far and would prefer to reuse 1 radwindow rather than adding 6 radwindows where the only real difference is the OnClientClose

    http://www.telerik.com/help/aspnet/window/radwindowobjectclientside.html so far, most everything I have tried from this link works.

    thanks

     

     

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4526 posts

    Posted 23 Jan 2012 Link to this post

    Hello Steven,

    Let me start with pointing you to the current documentation for the RadControls for ASP.NET AJAX, as the link you pasted if from the old, "Classic" suite's documentation which is no longer supported. Here begins the current version: http://www.telerik.com/help/aspnet-ajax/introduction.html and here the RadWindow's: http://www.telerik.com/help/aspnet-ajax/window-overview.html.

    Now, to your questions - attaching event handlers via JavaScritp is done via an explicit method, which is described here: http://www.telerik.com/help/aspnet-ajax/window-programming-setting-client-events-using-javascript.html. Please keep in mind that if you reuse the same window adding handler more than once will naturally result in it being called multiple times. What you can do to avoid this is to remove the handler in the OnClientClose event handler itself.

     An alternative solution is to declare two different RadWindows - one with the hander and one without it (or any other different configurations you may need) and use the one you need. You may find useful this article on the different ways to open a RadWindow: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html.

    Yet another option is to set the DestroyOnClose property of the manager to true so that each RadWIndow is disposed when it is closed. This will make sure you create a new instance each time and it will have only one handler attached (you can attach it only if need be, a simple if statement).

    I would also advise that you examine the current client-side API of the RadWindow here: http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html.


    Kind regards,
    Marin
    the Telerik team
    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 their blog feed now
Back to Top