Can I prevent [removed] from being called when doing an AJAX call

后端 未结 9 1655
北恋
北恋 2020-12-24 03:22

I have an AJAX-based grid control.

We hook into the window.onbeforeunload event to check if they have unsaved data and if so present them with a message \"Are you s

9条回答
  •  孤城傲影
    2020-12-24 04:03

    Not using AJAX, but still wanted to prevent leaving page with unsaved changes. I tried most of the prior suggestions, including navigateAway. None of them worked with IE 8. NavigateAway always returned length of 0.

    I did find a blog on that had solution about using class as ID in tag and then setting Boolean based upon that. I tried that, but it doesn't work because .NET when it outputs the HTML was wrapping the input tag in a span tag with the class declared in it. My final solution was to put the word Ignore in the ID name of the tag. Also, to prevent onbeforeunload being called before click is trapped by code that sets the Boolean, one must use , such as asp:Button or asp:Input. Finally, asp forces (of VS IDE does) the starting name to be the type of control; ID="Button_Save". Using asp: tags also prevents onbeforeunload from being called twice.

    
    
                                     
                  
提交回复
热议问题