window.onbeforeunload = saveChanges;
var changes = document.getElementById("<%=this.ButtonSubmit.ClientID%>").disabled;
event.returnValue = 'Changes were not saved. Click Cancel to go back and submit changes, or click OK to continue.';
document.getElementById("<%=this.ButtonSubmit.ClientID%>").disabled = false;
The first function: saveChanges() is called when ever the user tries to change the current page or close the browser. It just asks if they user wants to leave without saving.
The second function is called when ever a textbox, or other asp/html control has changed. This basically just enables the submit button.
So, within the page we might have a ASP.Net control like this:
<asp:textbox id="TextBox1" runat="server" onchange="enableSubmit()" width="49px"><asp:textbox>
<input id="ctl00_ContentPlaceHolder1_TextBox1" style="WIDTH: 49px" onchange="enableSubmit()" name="ctl00$ContentPlaceHolder1$TextBoxNotes">