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

show confirm window onbeforeunload

6 Answers 874 Views
Window
This is a migrated thread and some comments may be shown as answers.
Fakhrul
Top achievements
Rank 1
Fakhrul asked on 26 Feb 2009, 08:56 AM
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

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Feb 2009, 09:23 AM
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.
0
Fakhrul
Top achievements
Rank 1
answered on 26 Feb 2009, 09:52 AM
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.?


0
Fakhrul
Top achievements
Rank 1
answered on 01 Mar 2009, 08:30 AM
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
0
Fakhrul
Top achievements
Rank 1
answered on 27 Apr 2009, 02:34 PM
No solution or no Suggestions?
0
Georgi Tunev
Telerik team
answered on 28 Apr 2009, 05:59 AM
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.
0
Princy
Top achievements
Rank 2
answered on 28 Apr 2009, 02:13 PM
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.
Tags
Window
Asked by
Fakhrul
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Fakhrul
Top achievements
Rank 1
Georgi Tunev
Telerik team
Princy
Top achievements
Rank 2
Share this question
or