Peform check in radwindow before it can close

4 posts, 2 answers
  1. Stephan
    Stephan avatar
    71 posts
    Member since:
    Jul 2007

    Posted 20 Apr 2009 Link to this post

    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.
  2. Answer
    Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 22 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stephan
    Stephan avatar
    71 posts
    Member since:
    Jul 2007

    Posted 22 Apr 2009 Link to this post

    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?
  5. Answer
    Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 22 Apr 2009 Link to this post

    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.
Back to Top