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

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

17 Answers 903 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jason Maronge
Top achievements
Rank 1
Jason Maronge asked on 30 Sep 2007, 06:21 AM

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

17 Answers, 1 is accepted

Sort by
0
Jason Maronge
Top achievements
Rank 1
answered on 30 Sep 2007, 06:56 AM
Nevermind, I figured it out.  You have to use oWnd.add_Close(function)

Jason
0
HorseFly
Top achievements
Rank 1
answered on 02 Oct 2007, 02:40 AM

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

0
Georgi Tunev
Telerik team
answered on 02 Oct 2007, 12:00 PM
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
0
Sypher
Top achievements
Rank 1
answered on 03 Oct 2007, 03:06 AM
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?
0
Sypher
Top achievements
Rank 1
answered on 03 Oct 2007, 03:20 PM
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. :-)
0
Georgi Tunev
Telerik team
answered on 03 Oct 2007, 03:35 PM
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
0
Sypher
Top achievements
Rank 1
answered on 18 Oct 2007, 07:59 PM
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.
0
Mark DeMichele
Top achievements
Rank 1
answered on 25 Jan 2008, 10:50 PM
I too am experiencing the "Stack Overflow" problem. Does the latest version of Prometheus have a workaround besides compiling in Release mode?
0
Sypher
Top achievements
Rank 1
answered on 25 Jan 2008, 11:09 PM
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.
0
Georgi Tunev
Telerik team
answered on 29 Jan 2008, 03:44 PM
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
0
Skypy
Top achievements
Rank 1
answered on 21 Mar 2008, 03:07 PM
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
0
Georgi Tunev
Telerik team
answered on 21 Mar 2008, 03:19 PM
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
0
Elton
Top achievements
Rank 1
answered on 17 Apr 2008, 11:39 PM
Hello Telerik,

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

Regards,
Elton
0
Svetlina Anati
Telerik team
answered on 21 Apr 2008, 03:23 PM
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
0
Jeff
Top achievements
Rank 2
answered on 08 Jul 2008, 02:58 PM
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)
0
Elton
Top achievements
Rank 1
answered on 08 Jul 2008, 11:21 PM
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
0
chris
Top achievements
Rank 1
answered on 29 May 2009, 12:03 AM
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
Tags
Window
Asked by
Jason Maronge
Top achievements
Rank 1
Answers by
Jason Maronge
Top achievements
Rank 1
HorseFly
Top achievements
Rank 1
Georgi Tunev
Telerik team
Sypher
Top achievements
Rank 1
Mark DeMichele
Top achievements
Rank 1
Skypy
Top achievements
Rank 1
Elton
Top achievements
Rank 1
Svetlina Anati
Telerik team
Jeff
Top achievements
Rank 2
chris
Top achievements
Rank 1
Share this question
or