Hi Telerik,
I am trying to display a confirm message whenever users try to close a Radwindow. It works correctly when there is only 1 Radwindow, but got various problems in nested RadWindows(open Radwindow from another Radwindow). I tried different approaches based on samples I found in your forum. But none of them works for my scenario.
Basically, I want to achieve the following goals:
1. Whenever users click on the close button on the active Radwindow, the confirm should show up. If users click on OK, it should only close the active Radwindow. If users click on Cancel, user will stay on the current Radwindow.
2. Confirm message should only be displayed once. I often got duplicate confirm windows intermittently. I guess it is due to add_beforeClose got attached multiple times.
3. When I close the 2nd Radwindow and open it again from the 1st one and try to close it, the confirm prompt should be displayed again and only once. Right now, in my sample, the prompt is like in an infinite loop and cannot be closed.
Please find the code sinippets below.
function OnBeforeClose(sender, args) {
function callbackFunction(eventArgs) {
if (eventArgs) {
sender.remove_beforeClose(OnBeforeClose);
sender.close();
// sender.add_beforeClose(OnBeforeClose)
}
}
args.set_cancel(true);
radconfirm('Are you sure you want to close this window?', callbackFunction, 400, 140, null, 'Close Window');
}
Default.aspx:
Default2.aspx:
<telerik:RadWindow runat="server" ID="RadWindow1"></telerik:RadWindow>
<asp:Button ID="Button1" Text="open window" runat="server" OnClientClick="openWindow(); return false;" />
<script type="text/javascript">
function openWindow() {
var oWindow = window.radopen("Default3.aspx", "");
oWindow.setSize(400, 300);
oWindow.center();
oWindow.add_beforeClose(OnBeforeClose);
oWindow.show();
}
</script>
Default3.aspx is just a simple page with some text.
Here are steps to reproduce my problem:
1. Open Default2 form Default and open Default3 from Default2.
2. Close Default3 and open it again from Default2. Try to close Default3. You will get the prompt but cannot close it.
You can try different combination of those 3 pages. I want to always display confirm prompt correctly no matter how many times I open and close and no matter which Radwindow I am trying to close. Is there any way that I can make this work?
Thank you very much
I am trying to display a confirm message whenever users try to close a Radwindow. It works correctly when there is only 1 Radwindow, but got various problems in nested RadWindows(open Radwindow from another Radwindow). I tried different approaches based on samples I found in your forum. But none of them works for my scenario.
Basically, I want to achieve the following goals:
1. Whenever users click on the close button on the active Radwindow, the confirm should show up. If users click on OK, it should only close the active Radwindow. If users click on Cancel, user will stay on the current Radwindow.
2. Confirm message should only be displayed once. I often got duplicate confirm windows intermittently. I guess it is due to add_beforeClose got attached multiple times.
3. When I close the 2nd Radwindow and open it again from the 1st one and try to close it, the confirm prompt should be displayed again and only once. Right now, in my sample, the prompt is like in an infinite loop and cannot be closed.
Please find the code sinippets below.
function OnBeforeClose(sender, args) {
function callbackFunction(eventArgs) {
if (eventArgs) {
sender.remove_beforeClose(OnBeforeClose);
sender.close();
// sender.add_beforeClose(OnBeforeClose)
}
}
args.set_cancel(true);
radconfirm('Are you sure you want to close this window?', callbackFunction, 400, 140, null, 'Close Window');
}
Default.aspx:
<telerik:RadWindow runat="server" ID="RadWindow1"></telerik:RadWindow>
<asp:Button ID="Button1" Text="open window" runat="server" OnClientClick="openWindow(); return false;" />
<script type="text/javascript">
function openWindow() {
var oWindow = window.radopen("Default2.aspx", "");
oWindow.setSize(600, 400);
oWindow.center();
oWindow.add_beforeClose(OnBeforeClose);
oWindow.show();
}
</script>
<asp:Button ID="Button1" Text="open window" runat="server" OnClientClick="openWindow(); return false;" />
<script type="text/javascript">
function openWindow() {
var oWindow = window.radopen("Default2.aspx", "");
oWindow.setSize(600, 400);
oWindow.center();
oWindow.add_beforeClose(OnBeforeClose);
oWindow.show();
}
</script>
Default2.aspx:
<telerik:RadWindow runat="server" ID="RadWindow1"></telerik:RadWindow>
<asp:Button ID="Button1" Text="open window" runat="server" OnClientClick="openWindow(); return false;" />
<script type="text/javascript">
function openWindow() {
var oWindow = window.radopen("Default3.aspx", "");
oWindow.setSize(400, 300);
oWindow.center();
oWindow.add_beforeClose(OnBeforeClose);
oWindow.show();
}
</script>
Default3.aspx is just a simple page with some text.
Here are steps to reproduce my problem:
1. Open Default2 form Default and open Default3 from Default2.
2. Close Default3 and open it again from Default2. Try to close Default3. You will get the prompt but cannot close it.
You can try different combination of those 3 pages. I want to always display confirm prompt correctly no matter how many times I open and close and no matter which Radwindow I am trying to close. Is there any way that I can make this work?
Thank you very much