show confirm window onbeforeunload

7 posts, 0 answers
  1. Fakhrul
    Fakhrul avatar
    26 posts
    Member since:
    Aug 2008

    Posted 26 Feb 2009 Link to this post

    Hi, how can i show confirm window  onbeforeunload? its because if user made any changes and didn't save and try to close the window, I need to show a confirm message window to notify the user. i have gone through some post regarding this, but couldnt find any particular solution. how can i do this? any sample code?

    Thanks in advance

    Mamun
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Feb 2009 Link to this post

    Hi Fakhrul,

    Try adding the following client side code and see whether its working.

    JavaScript:
    <script type="text/javascript"
    Telerik.Web.UI.RadWindow.prototype.oldClose = Telerik.Web.UI.RadWindow.prototype.close;    
    Telerik.Web.UI.RadWindow.prototype.close = function(arg)    
    {    
        if (this.get_name() == "RadWindow1")  
        {  
            var result = confirm("Are you sure you want to close RadWindow1");    
            if (result) this.oldClose(arg);   
        }  
        else  
        {  
            this.oldClose(arg);  
        }       
    }           
    </script> 

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
        <Windows> 
            <telerik:RadWindow ID="RadWindow1" runat="server" Behavior="Default" InitialBehavior="None" Left="" NavigateUrl="http://www.telerik.com" OpenerElementID="btnTelerik"
            </telerik:RadWindow> 
        </Windows> 
    </telerik:RadWindowManager> 
    <asp:Button ID="btnTelerik" runat="server" Text="Telerik" />   

    Thanks,
    Shinu.
  3. Fakhrul
    Fakhrul avatar
    26 posts
    Member since:
    Aug 2008

    Posted 26 Feb 2009 Link to this post

    Thanks for your reply.
    Sorry its doesnt work.

    window isnt radwindow. its a simple aspx page and it doesn't open with radwindow. In this case how can i do this.?


  4. Fakhrul
    Fakhrul avatar
    26 posts
    Member since:
    Aug 2008

    Posted 01 Mar 2009 Link to this post

    Is there no way to show radconfirm when user click on "X" of a aspx window?

    Note: This window does not open with rad window. from this window several rand window open and this window contains scriptmanager and a radwindowanager.

    Thanks

    Mamun
  5. Fakhrul
    Fakhrul avatar
    26 posts
    Member since:
    Aug 2008

    Posted 27 Apr 2009 Link to this post

    No solution or no Suggestions?
  6. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 28 Apr 2009 Link to this post

    Hi Fakhrul,

    Using radconfirm in onbeforeunload is not possible because radconfirm cannot block the execution thread. For such scenario we recommend to use the standard confirm dialog.


    Sincerely yours,
    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.
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Apr 2009 Link to this post

    Hello Fakhrul,

    You can try out the following code snippet for showing standard confirm dialog when closing the page.

    [javascript]
     
    <script type="text/javascript">   
      window.onbeforeunload = function (event) {  
      var message = 'All changes will get lost!';  
      if (typeof event == 'undefined') {  
        event = window.event;  
      }  
      if (event) {  
        event.returnValue = message;  
      }  
      return message;  
    }  
    </script>  

    Thanks,
    Princy.
Back to Top