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

RadPrompt with window onbeforeunload

1 Answer 153 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 17 Dec 2012, 12:32 PM
Hello All,
I want on my page to force user to save all data before leaving page.
I have used Radprompt with window.onbeforeunload but it will give me two pop-ups one from IE and Other from RadPrompt.
I want only window from RadPrompt.
Can anybody help me for the issue.

Sample code as :

 

<script type="text/javascript"> 

 

var needToConfirm = true;

window.onbeforeunload = confirmExit;

 

function confirmExit() {

 

var ss;

 

 

if (needToConfirm)

{

ss= radalert(

 

'Save personal information', 350, 150, 'MY Message', null, null);

 

}

}


Thanks in advc.

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 17 Dec 2012, 03:42 PM
Hello Sandeep,

You cannot cancel this event with custom code, as this would allow websites to effectively prevent the user from closing his/her browser, which is not desirable.

More information on handling this event and showing such a confirmation is available in the net, for example:
http://tim.mackey.ie/HowToCancelAnOnbeforeunloadEvent.aspx
http://msdn.microsoft.com/en-us/library/ie/ms536907(v=vs.85).aspx

When this event returns a non-void value, for example a string, the user is prompted to confirm the page unload and this browser popup will always be shown even if you add some other code there (e.g. a RadConfirm/RadPrompt) and only the browser dialog will be taken into account by the browser.

Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or