function
confirm(text) {
var
oManager = GetRadWindowManager();
var
oWnd = oManager.open(
null
,
"RadWindow6"
);
oWnd.SetTitle(text);
}
<
telerik:RadWindow
ID
=
"RadWindow6"
runat
=
"server"
Animation
=
"None"
Behavior
=
"Default"
Height
=
"170px"
InitialBehavior
=
"None"
Left
=
""
Modal
=
"True"
NavigateUrl
=
"~/popups/ConfirmWindow.aspx"
OnClientClose
=
"OnClientClose"
Overlay
=
"True"
Top
=
""
VisibleStatusbar
=
"False"
Width
=
"360px"
Skin
=
"WebBlue"
Behaviors
=
"Move,Close"
>
</
telerik:RadWindow
>
and here's the script that is added to a close button on the ConfirmWindow.aspx page which is inside this radwindow (works and closes the window as expected) :
function
CloseWindow(type) {
var
oWnd = GetRadWindow();
var
oArg =
new
Object();
oArg.result =
false
;
oArg.type = type;
oWnd.close(oArg);
}
the javascript func is opening radwindow and my close button is closing the window but OnClientClose is not working, not even seeked! What am I missing?
11 Answers, 1 is accepted
btw Gimmik, the topic is only about my OnClientClose function not firing and you're asking me if its firing.interesting =)
To be fair, a function that is not working and a function that is not fired at all are 2 different scenarios in many cases :)
Anyway, when you say that the function is not working, I assume that even if you add a standard alert in that function, it is not fired at all, is that so? If yes, you most probably have a second RadWindowManager on that page. In such case, you need to take into consideration the following:
1. All RadWindowManager's functions (radopen, radalert, radconfirm, radprompt, GetRadWindowManager, etc) are always using the first rendered RadWindowManager on the page.
2. Every RadWindowManager "knows" only the RadWindows that are declared in its Windows collection.
This means that if you have a RadWindow2 as a standalone control OR declared in RadWindowManager2, and you use something like radopen(myUrl, "RadWindow2");, radopen will use RadWindowManager1 and will open a new RadWindow with the settings taken from RadWindowManager1.
To avoid that problem, when you have multiple managers on a page, you need to get a reference to the correct RadWindowManager first and then call its methods.
e.g.
var manager = $find("<%= RadWindowManager2.ClientID %>");
manager.open(myUrl, "RadWindow2");
I hope this information helps. If it doesn't, please open a support ticket and send me the code for the masterpage and the problematic content one, so I could check them.
Greetings,
Georgi Tunev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Here I draw a picture of my scenario (this new paint is funny =) ) http://img189.imageshack.us/img189/3250/unledqze.png
my aspx and ascx were both implementing OnClientClose functions but the problematic page was my aspx. I found out that the radwindow on my aspx was triggering the OnClientClose func on ascx as I am using the same RadWindow on both pages.
I feel stupid not to think of this before..
Guys, I can't find a solution to my problem related to OnClientClose not triggering.
1. i don't have more than one RadWindowManager.
2. I don't have more than one listener to OnClientClose, like explained by Baris.
3. I have it as simple as the example here, http://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/events/onclientclose
Below is what I have, and when the call oWnd.close() is made the onEulaClose is not fired.
Any help will be appreciated.
EULA.aspx (Called page by Default):
<script type="text/javascript">
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
function DoAccept() {
var oWnd = GetRadWindow();
oWnd.close();
}
</script>
<asp:Button ID="btn_close" runat="server" Text="I Accept" OnClick="DoAccept_Click" />
The code behind DoAccept_Click, eventually calls back into Javascript's function DoAccept()
Default.aspx (Calling page):
<script type="text/javascript">
function onEulaClose(sender, args) {
alert('got here');
}
function displayEULAMessage() {
var oWnd = radopen("/EULA.aspx", "eulaWin");
setBehaviors(oWnd);
},
function setBehaviors(oWnd) {
oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.None);
oWnd.set_visibleStatusbar(false);
oWnd.set_modal(true);
}
</script>
<telerik:RadWindowManager ID="rwm1" runat="server">
<Windows>
<telerik:RadWindow ID="eulaWin" RenderMode="Lightweight" runat="server" Behaviors="None" KeepInScreenBounds="true" Skin="WebBlue" EnableEmbeddedSkins="false" IconUrl=""
Height="550px" Width="800px" Modal="true" BorderStyle="None" ShowContentDuringLoad="false" ReloadOnShow="false" VisibleStatusbar="false" Title="EULA"
OnClientClose="onEulaClose"/>
</Windows>
</telerik:RadWindowManager>
Hello, I am seeing this issue as well. I am passing the rad window manager and open with that manager, but the OnClientClose would execute only on the first call and the subsequent calls would fail to call it. Anything else I need to do?
var manager = $find("<%= RadWindowManager2.ClientID %>");
manager.open(myUrl, "RadWindow2");
Hello Ranjith,
A potential cause of the event not firing on window close might be a JavaScript exception on the page. Please ensure you don't have any errors on the page. I suggest using the Browser's developer tools to inspect the page and monitor it for JavaScript exceptions. For more information/tips, please check out the "Debug JavaScript" section of the Improve Your Debugging Skills with Chrome DevTools Blog Post.
Here is a sample scenario that shows opening a RadWindow on button click. The OnClientClose event handler is attached to the RadWindow. Each client close will log a message on the console.
Markup
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
<Windows>
<telerik:RadWindow ID="RadWindow1" runat="server" OnClientClose="clientClose"></telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
<telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" OnClientClicked="clientClicked" AutoPostBack="false"></telerik:RadButton>
JavaScript
function clientClicked(sender, args) {
var manager = $find("<%= RadWindowManager1.ClientID %>");
var wind = manager.open(null, "RadWindow1");
}
function clientClose(sender, args) {
console.log("window closed");
}
You may also find the following articles helpful:
I hope that will help.
Kind regards,
Doncho
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hi Doncho,
Thanks for the quick reply. Yes, there are no Javascript errors of any kind. It "does" execute the close script once or twice, but on the "subsequent" calls, it doesn't call!
Hello Ranjith,
At this point, we are stepping in the dark. To be able to help, we would require more information about the current configuration and/or describe the steps that will help us replicate the problem locally.
Once we can see the problem, we will debug the issue and share the details.
Kind regards,
Doncho
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Ranjith, you may be able to manually assign the close function when you open the window.
something like
wind.add_close(clientclose);
placed just after your manager.open line worked for me when I had a similar issue.