client close from popup window

7 posts, 0 answers
  1. JOSE MANUEL PÉREZ RAMÍREZ
    JOSE MANUEL PÉREZ RAMÍREZ avatar
    22 posts
    Member since:
    Jan 2008

    Posted 03 Feb 2009 Link to this post

    I have one webform (A) and opens (B). 
    when user close (B) with close window button  (X behavior close) method. i want to execute a method from B window.
     Is posible
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2009 Link to this post


    Hi Jose Manuel,

    You can attach the method to onbeforeunload with window-B for executing it before closing the RadWindow. Also make sure that you set the property DestroyOnClose="true" of the RadWindowManager.

    ASPX:
    <body onbeforeunload="HandleOnClose()"

    JavaScript:
    <script type="text/javascript">  
    function HandleOnClose()  
    {  
        // Add your code  
    }  
    </script> 

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ole
    Ole avatar
    1 posts
    Member since:
    Nov 2008

    Posted 04 Feb 2009 Link to this post

    sadly onbeforeunload does not work on firefox :(
  5. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 04 Feb 2009 Link to this post

    Hello Jose,

    You can use OnClientClose event of the RadWindow control and attach to it a function, which is on the 'WebForm A' as showed bellow :

    RadWindow declaration on the 'WebFormA' :

    <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" NavigateUrl="WebFormB.aspx" 
    OnClientClose="OnClose"


    OnClose function on the 'WebFormA' :

    <script type="text/javascript"
        function OnClose(sender, args) 
        { 
            // Call your functions 
            alert(" FORM 'A' "); 
        } 
    </script> 


    More details for the RadWindow methods can be found in this help page.

    I hope this helps.

    Sincerely yours,
    Fiko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Patrick
    Patrick avatar
    10 posts
    Member since:
    Apr 2009

    Posted 13 May 2009 Link to this post

    Hey,

    I have the same problem but the solution over do not solve it.

    I want to have a Value from (B) in (A).

    In my case I have a Rotator in my Window and want to have the CurrentIndex in (A). I have already a "Close"-Button which works good. But I want the same behaviour on the X-Button of Window (B).

    Short: Call a js-function of window (B) when regular closebutton from window is pushed.

    I hope you understand my problem.

    I already tried this: Overwrite the Close Method but doesn´t work.

    Thanks.

    Patrick


  7. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 14 May 2009 Link to this post

    Hi Patrick,

    You do not need to override the close() function. Bellow, I describe the steps that are implemented in the attached demo project.
    • on the content page I have implemented the following simple logic :
      • attach handler to the OnClientShown event of the RadRotator control.
      • in that event get the reference to the current showed item and get its index in the items' collection :
        var currentIndex = args.get_item().get_index();// Get the current index  
      • store that value in a custom property of the RadWindow object :
        GetRadWindow().MyCustomProperty = currentIndex; // Store the current index 
      Every time when the new item is shown, the MyCustomProperty will be updated with the current index.
    • you can access the MyCustomProperty in the OnClientClose handler of the RadWindow object on the parent page as follows :
      function OnClientClose(oWindow, args) 
          alert("Current index : " + oWindow.MyCustomProperty); 

    This approach will work in both scenarios : by clicking the X-button or by closing the window programmatically - oWindow.close().

    I hope this helps.

    Greetings,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Patrick
    Patrick avatar
    10 posts
    Member since:
    Apr 2009

    Posted 14 May 2009 Link to this post

    Hello Fiko,

    I understood it, tried it and it works pretty well.

    I appreciate your support! Thank you so much. :)

    My code is much cleaner now.

    Greetings Patrick


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017