<p>I'd like to warn users when they <strong>try to close a browser window</strong> if they <strong>didn't save</strong> the changes they made in the web form.</p>

<p>I'm using ASP.NET 3.5 (with ASP.NET Ajax).</p>

<p>Is there a common solution which I could easily implement?</p>

<p><em>EDIT: maybe my question wasn't clear:</em> I am specifically looking for a way which integrates gracefully in the <strong>ASP.NET</strong> Server Controls methodology.</p>

On the Page_Unload event (or call this function in your body tag,
```
<body onunload="onPageUnload();">
```
), you can have a check if the form has data in it.  Then you could run some Java:
```
```
<script language="text/javascript">
   function onPageUnload() {
        var oConfirm = window.confirm("You have unsaved form data, are you sure you want to close this window?");
        if(oConfirm){
            //Close
        }else{
            //Dont 
        }
    }
</script>
```
```
See how that works out for ya
EDIT:  It may not prevent the closing of the window, but it will alert your user that they have unsaved data in your form.
Confirmed does NOT work cross-browser, I will investigate a different method and post it up here.