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

Peform check in radwindow before it can close

3 Answers 109 Views
Window
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 20 Apr 2009, 04:31 PM
Hi, can someone help me with the following scenario. I have a master page which holds the definition of a radwindow which is shown in modal mode. In this window I have a toolbar and a TextBox. As soon as the user edit something in the TextBox, I will set a hidden field to true so I know the data has changed. Now when the user click on the close button (actual the cross in the right corner) and didn't save the data, I want to show a confirmation window which asks to save the modified data or just close the window.

  1. How can I check in the master page, which holds the window definition and some javascript functions to refresh the page when the windows closes, if the hidden field in the modal window is set to true?
  2. How can I then show the modal dialog?
  3. How can I save the data if the user decides to save the data?

A other possibility would be, when the user wants to save the data, the close action is canceled, so he can save the data using the button in the radwindow.

I use version Q3 2008 1105.35 of the Rad-Ajax controls. We cannot upgrade to the lastest version yet. So using onBeforeClose is not an option.

3 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 22 Apr 2009, 12:29 PM
Hello Stephan,

I suggest to use the following code in your page just before the window declaration:

<script type="text/javascript">  
Telerik.Web.UI.RadWindow.prototype.oldClose = Telerik.Web.UI.RadWindow.prototype.close;  
Telerik.Web.UI.RadWindow.prototype.close = function(callBackFnArg)  
{  
    //your code goes here  
    alert("closing");  
    //call old close method to close the RadWindow
    this.oldClose(callBackFnArg);  
};  
</script>  
<telerik:RadWindow id="yourWindow" runat="server" ... 

This code overrides the close() window method which is called when you click the close button.
From this point on you could develop your custom logic that would check if your conditions are met before closing the window.

As for checking variables in the content page, you can get a reference to the content page by using the get_contentFrame() method. e.g.
var oWnd = GetRadWindowManager().getWindowByName(  "RadWindow1"); 
var contentWin = oWnd.get_contentFrame().contentWindow; 
There you could find the hidden field and check its value.



Regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Stephan
Top achievements
Rank 1
answered on 22 Apr 2009, 02:08 PM
Hi Georgi, thanks for the reply. What about if I use a masterpage containing a RadWindowManager. I only need the closing functionaltiy for a specific window. Is it possible to set it just for one of the windows defined in the RadWindowManager instead of all of them?
0
Accepted
Georgi Tunev
Telerik team
answered on 22 Apr 2009, 02:42 PM
Hello Stephan,

Yes, this is possible - you can examine the code in this forum post to see how such check could be implemented.

Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Window
Asked by
Stephan
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Stephan
Top achievements
Rank 1
Share this question
or