
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

Jason

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
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

Is there a way to clear the close or a way to see if it is already set before calling add_close?

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

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.


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

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
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

With the release of RadWindow for AJAX, can this problem be fixed?
Regards,
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

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)

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

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