How to stop firing onbeforeunload function on RadGrid Postbacks in ASP.NET

shababjo

New Member
Scenario: I have onbeforeunload function on .aspx page which I am using to display a message before navigating away from current page (ASP.NET Application). This page is quite complex where post backs are happening at quite a few times e.g. I have multiple buttons, Rad Grid, Rad Window PopUps etc.So, all the buttons call onbeforeunload whenever they are clicked and message box is being called un-necessarily. To prevent onbeforeunload message displaying I am just calling another cancelEvent function on button's OnClientClick event where I am just calling null. By doing this all the button post backs are handled but the RadGrid which I am using has Button Columns (Delete) and whenever a row is deleted from the grid it offcourse refreshes the grid which ultimately calls onbeforeunload.Could please anyone tell me how I can prevent onbeforeunload when I delete anything from RadGrid. Following is the code snippet that I am using and working fine for buttons but I need help for grid delete column may be some event like Button's OnClientClick event that I can use to call my cancelEvent.\[code\]window.onbeforeunload = confirmExit;function confirmExit() { window.event.returnValue = 'http://stackoverflow.com/questions/12801334/If you navigate away from this page any unsaved changes will be lost!';}function cancelEvent(event) { window[event] = function () {null}}<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" CssClass="ActionButtons" ValidationGroup="vsDataEntry" OnClientClick="return cancelEvent('onbeforeunload')"/>\[/code\]Regards
 
Back
Top