OnClientClose|ClientCallBackFunction not firing after window.close(arg) is called

18 posts, 0 answers
  1. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 30 Sep 2007 Link to this post

    Has anyone gotten the OnClientClose or ClientCallbackFunction method to fire when a window is closed?  I am opening a window but neither method gets called anymore.  Below is my code:

                    var url = "<%=DocuSys.DocuView.SitePages.PreOp.Screening%>?showheader=" + showheader;  
                    var oWnd = window.radopen(url,null);   
                    oWnd.set_Status(url);  
                    oWnd.set_Title("Drug Screening");   
                    oWnd.setSize(_docWidth - 30, _docHeight - 130);   
                    oWnd.center();         
                    oWnd.<OnClientClose|ClientCallBackFunction> = function (radWindow, returnValue)  
                                                  {     alert("returnValue");  
                                                        if(returnValue == "accept")  
                                                        {  
                                                            SignPreop();  
                                                        }  
                                                  } 



    The <OnClientClose|ClientCallBackFunction> is to show I have tried both of those methods. 

    Jason

  2. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 30 Sep 2007 Link to this post

    Nevermind, I figured it out.  You have to use oWnd.add_Close(function)

    Jason
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. HorseFly
    HorseFly avatar
    35 posts
    Member since:
    Aug 2006

    Posted 01 Oct 2007 Link to this post

    Would someone elaborate on the add_Close() function?  What is the definition?  Maybe an example of how to open a window and set the event from javascript.  Also, does that function work when opening a window from another window?  Such as Main Page - > Window1 - >Window 2

  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 02 Oct 2007 Link to this post

    Hello HorseFly,

    Such example can be found in the documentation, section Controls / RadWindow / RadWindow Client-Side / RadWindow Object Client-Side Object Model.

    For convenience I am pasting it below:

    //Set the OnClientClose dynamically by using the ASP.NET AJAX convention.  
    //Useful for RadWindows created on the client.  
    function OpenWin()     
    {  
       var oWnd = radopen("Dialog.aspx"null);         
       oWnd.add_Close(OnClientCloseWin);     
    }     
     
    function OnClientCloseWin()  
    {             
       //Your code here             
       alert('Closed');  
    }  
     

    Regarding your second question, yes it will work by using get_ContentFrame().contentWindow:

    //Call a predefined function in opened RadWindow  
    function CallFn()  
    {  
       var oWnd = $find("<%=RadWindowManager1.ClientID %>").getWindowByName("RadWindow1");  
       oWnd.get_ContentFrame().contentWindow.CalledFn(); //CalledFn() must exists in the RadWindow's content  
    }  
     



    Greetings,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Sypher
    Sypher avatar
    79 posts
    Member since:
    Aug 2006

    Posted 02 Oct 2007 Link to this post

    Is there any other documentation on the add_close function?  I'm having a problem now because the DestroyOnClose isn't working, and every time the window is opened again, the add_close is, well, added on top of the last one.

    Is there a way to clear the close or a way to see if it is already set before calling add_close?
  7. Sypher
    Sypher avatar
    79 posts
    Member since:
    Aug 2006

    Posted 03 Oct 2007 Link to this post

    Nevermind.  The problem I'm having isn't what I thought it was.  The add_close isn't being duplicated.  I'm getting a stack overflow error from the add_close *sometimes*.  I'll have to send some code to show what's happening. :-)
  8. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 03 Oct 2007 Link to this post

    OK sypher,

    If you manage to isolate the problem, please send us the project in a support ticket (you cannot attach files in the forum) and we will check it right away.



    Sincerely yours,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Sypher
    Sypher avatar
    79 posts
    Member since:
    Aug 2006

    Posted 18 Oct 2007 Link to this post

    For anyone looking for more info on the stack overflow, I did open a support ticket for this and Telerik did find a problem that seems to only show up when debugging is turned on in the project.  To work around it, we have to set <compilation debug="false"> in the web.config and compile in release mode.

    And with the add_close being added multiple times and the DestroyOnClose not working, I'm back to having problems with those and will try to open a separate ticket on that as soon as we can get a simpler sample put together.
  10. Mark DeMichele
    Mark DeMichele avatar
    74 posts
    Member since:
    Oct 2005

    Posted 25 Jan 2008 Link to this post

    I too am experiencing the "Stack Overflow" problem. Does the latest version of Prometheus have a workaround besides compiling in Release mode?
  11. Sypher
    Sypher avatar
    79 posts
    Member since:
    Aug 2006

    Posted 25 Jan 2008 Link to this post

    Nope.  It's a pain in the butt, but that's the only way so far.  Telerik says it's a Microsoft compiler issue.  As far as I know, Telerik isn't working on a fix any longer.  I don't know if they contacted Microsoft to try to resolve it.
  12. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 29 Jan 2008 Link to this post

    Hi sypher,

    The problem is not with the compiler but in the debug code that is executed on the client when compilation debug is set to true.

    I can assure you that we haven't abandoned this case, however at this point the only workaround is still to set debugging to false. If we find an appropriate solution that can be implemented on our side, we will include it in a following hotfix right away.


    Sincerely yours,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. Skypy
    Skypy avatar
    31 posts
    Member since:
    Nov 2007

    Posted 21 Mar 2008 Link to this post

    Hello support Team,

    I need to use add_Close but for development purpose I hardly need to stay in debug, will this 'bug' be corrected in next Prometheus build (end of march) ?

    Thanks
  14. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Mar 2008 Link to this post

    Hello Skypy,

    We researched the issue further and verified it as unfixable. The problem is with the way MS AJAX extends built-in javascript classes, such as String, Function, Array - it fails to work when examining for debugging purposes such objects from another window

    This is a general MS AJAX issue that can be reproduced in scenarios without having any Telerik control. We tried various approaches but unfortunately we cannot fix the problem from our side.


    Kind regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  15. Elton
    Elton avatar
    98 posts
    Member since:
    Oct 2007

    Posted 17 Apr 2008 Link to this post

    Hello Telerik,

    With the release of RadWindow for AJAX, can this problem be fixed?

    Regards,
    Elton
  16. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 21 Apr 2008 Link to this post

    Hello Elton,

    As my colleague has explained, unfortunately there is still no workaround for this issue. We are still researching but it seems that the problem will not be solved soon.

    Sincerely yours,
    Svetlina
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  17. Jeff
    Jeff avatar
    3 posts
    Member since:
    May 2008

    Posted 08 Jul 2008 Link to this post

    I may have found somewhat of a workaround for this.  It might not work in all situations, but for what I needed, it works perfectly:

    function OpenWindow(url)  
    {  
      var oWnd = radopen(url,'SomeNewWindow');  
      oWnd.argument = document;       
    }  
     
    function WindowCallBack(someText)  
    {  
      alert(someText);  

    I pass the document of the calling page into the argument field of the new window.  Then, when you want to close the window, call the function and use its argument property:

    function CloseWindow()     
    {     
      var oWnd = GetRadWindow();     
      var referringDoc = null;   
      if(oWnd.argument != null)     
      {     
        referringDoc = oWnd.argument;     
      }     
      if(referringDoc!= null)     
      {     
        referringDoc.parentWindow.WindowCallBack('I love apples');     
      }     
    }    
     

    I'm not positive if the "parentWindow" will work in all scenarios, so you might have to debug it a little bit.  For me, this works even with postbacks. (which i thought was odd, but it still worked)
  18. Elton
    Elton avatar
    98 posts
    Member since:
    Oct 2007

    Posted 08 Jul 2008 Link to this post

    Thanks Jeff,

    I think we can pass the "WindowCallBack" as the wnd.argument and call the window.onunload() js function to fire "WindowCallBack".

    But still this is not from telerik functionality and it may suffer from unknown problems...

    Cheers,
    Elton
  19. chris
    chris avatar
    22 posts
    Member since:
    Aug 2012

    Posted 28 May 2009 Link to this post

    Thank you for .add_close()

    just want to point out that it should be all lower case add_close() vs add_Close()

    http://www.telerik.com/help/aspnet-ajax/window_programmingradwindowmethods.html
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017