
I'm trying to do some fancy stuff when my radwindow is closed (using the 'x'). Therefore I use the onClientClose-Event of the RadWindowManager (as noticed in different forum-topics here)
So my site looks like this:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DetailEmail.aspx.cs" Inherits="waPMHI.dlg.DetailEmail" %> |
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml" > |
<head runat="server"> |
<title>E-Mail</title> |
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=utf-8" /> |
<link rel="stylesheet" type="text/css" href="../Styles/pmhi.css" /> |
<telerik:RadCodeBlock ID="RadCodeBlock12" runat="server"> |
<script language="javascript" type="text/javascript"> |
// [... other functions ...] |
function machzu() { |
alert('zu'); |
} |
</script> |
</telerik:RadCodeBlock> |
</head> |
<body class="mailTableBack""> |
<telerik:RadWindowManager ID="SingletonSkinFix" runat="server" Skin="Web20" OnClientClose="machzu()"/> |
<form id="wrapper" runat="server" |
style="height: 100%; width: 100%; "> |
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" ></telerik:RadScriptManager> |
<telerik:/RadAjaxPanel> |
<%-- [... a lot of other stuff ...] --%> |
</form></body></html> |
Any idea why there is this weird behaviour?
9 Answers, 1 is accepted

I am not sure what is happening at your end. I tried the scenario and it is working fine on my end. You should put only the function's name without the ( and ) brackets as a value of the OnClientClose property. Try removing the brackets in the function call and see whether it is working fine.
ASPX:
<telerik:RadWindowManager ID="SingletonSkinFix" runat="server" OnClientClose="machzu"> |
<Windows> |
<telerik:RadWindow ID="window1" runat="server" VisibleOnPageLoad="true" NavigateUrl="http://www.google.com"></telerik:RadWindow> |
</Windows> |
</telerik:RadWindowManager> |
JavaScript:
<script language="javascript" type="text/javascript"> |
function machzu() |
{ |
alert('Window Closed'); |
} |
</script> |
Thanks,
Shinu.

try with this....
function
openRadWindow(CustomerID)
{
var oWnd = radopen("AddPopup.aspx?CustomerID=" + CustomerID, "RadWindow1" );
oWnd.Center();
oWnd.add_close(OnClientCloseWin);
}
function OnClientCloseWin()
{
alert(
"Clsoing");
}
<html>
on click of any buttons open the window like onclik="openRadWindow('test'); return false;"
...
then add the function oWnd.add_close(OnClientCloseWin); .. its working fine....

try with this....
function
openRadWindow(CustomerID)
{
var oWnd = radopen("AddPopup.aspx?CustomerID=" + CustomerID, "RadWindow1" );
oWnd.Center();
oWnd.add_close(OnClientCloseWin);
}
function OnClientCloseWin()
{
alert(
"Clsoing");
}
<html>
on click of any buttons open the window like onclik="openRadWindow('test'); return false;"
...
then add the function oWnd.add_close(OnClientCloseWin); .. its working fine....
By
Lenin(tlenin@insoft.com)
The problem comes from the way you have attached the handler - when you add the brackets (), you actually call and execute the function once. In order to attach a handler you should not call the function, but you should only provide the function's name - in this manner it will not be called once but it will executed every time the particular event fires.
Sincerely yours,
Svetlina
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Well... Still looks like we talk about different stuff...
I do *not* want to react when *another* window I opened before is closed but the window I am actually in at the moment. (So I can save Textfield-Values before closing, etc.)
Is there a KB-Article/Hint/Whatever how to solve that problem?
Just found out it is absolutely the same as in this Topic I want to achieve...: Client Close From Popup Window

But the firefox(3.0)-behaviour is a bit weird at this point.
In my case the onbeforeunload-Event is not fired when closing the window by mousclick, but when I reload the page (F5) (which also causes the window to close)
Is this the normal FF-behaviour or am I doing something wrong?
Let me check if I understand your scenario correctly. You want to validate some element in the content page before closing the window. For example if a textfield is empty, you don't want that RadWindow to be closed until the user fill it, am I right?
If this is so, you can either use OnClientBeforeClose or as an alternative - to remove the closing button from RadWindow by using the Behaviors property and close it only from a button inside the content page. In the last scenario, you would call GetRadWindow.close() only after the validation is successful.
Let me know what approach you would like to use (or if I haven't understood your scenario completely) and I will prepare a small sample that will show how to achieve the desired behavior.
All the best,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

OnClientBeforeClose looks like the right decision but afaik you use it in the radWindowManager of the calling window, not in the window that is opened itself?
In other words:
Window A opens Window B. When window B is closing I want to do some stuff in Window B.
I thought OnClientBeforeClose just works this way:
Window A opens Window B. When window B is closing I can do some stuff in Window A
Thats what I suspect from the examples.
Yes, the function must be executed in the context of the parent page - the one from which the RadWindow was created. Still you can get a reference to the content page from the parent one and call a function there (in the content) that would validate the fields for your.
Please check the following help topic that shows how to call functions in RadWindow in different scenarios:
http://www.telerik.com/help/aspnet-ajax/window_programmingcallingfunctions.html
Kind regards,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.