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

[Solved] Cancelling Window Close

3 Answers 204 Views
Window
This is a migrated thread and some comments may be shown as answers.
etrich
Top achievements
Rank 1
etrich asked on 11 Mar 2008, 02:37 AM
What is the suggested approach to cancel a window from being closed?

The scenario we would like to implement is the following:

- the user clicks on X to close the Window
- we initiate a callback to the page that lives inside the window to make sure the window can be closed in it's current state
- if the server page notifies that the Window cannot be closed, keep the window opened

Since there is only a closed event and no closing event, how can we implement this scenario?

Thank you

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 11 Mar 2008, 07:38 AM
Hi etrich,

I am not sure if I understand your scenario completely, but I would recommend to remove the Close behavior of the RadWindow (by using the Behaviors property) and to make the window close only when a button inside is is clicked. Then you can check for the required conditions when the user clicks the closing button and if they are met - to call GetRadWindow().close() (assuming that you have the GetRadWindow() function declared on the content page).

I hope this helps. If you experience problems implementing the desired functionality with RadWindow, I suggest to build your logic by using a standard popup (window.open()). Once you are ready, send us the working implementation and we will rework it for you so it uses RadWindow.

All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
etrich
Top achievements
Rank 1
answered on 11 Mar 2008, 01:55 PM
Thanks for the information Georgi.

It is obvious that we can cancel the window from closing by using custom buttons in our window and checking for proper conditions before closing the window.

Howerver, we would like to be able to cancel a window from closing when the use clicks on the X button. Removing the X button would give less usability to the end user and we would like to keep it.

Would setting the DestroyOnClose to false, then showing back the window when we realize the window cannot be closed using the Show method, do the trick? If not, any other hacks or techniques we could use?

Thanks!
0
Georgi Tunev
Telerik team
answered on 11 Mar 2008, 04:34 PM
Hello etrich,

The "DestroyOnClose" approach will not work in this case. As for canceling the closing, currently it cannot be implemented in the way that you suggest. The main issue here is that the Ajax callback that you wish to do is asynchronous - e.g. once the X is clicked you need to "decide" immediately whether to close the window or not - you cannot wait for the result of the asynchronous callback. We will consider adding an OnClientBeforeClose event for the RadWIndow, but this would happen in a future version of the control.




Sincerely yours,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Window
Asked by
etrich
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
etrich
Top achievements
Rank 1
Share this question
or