User closes out Internet Explorer, what to do? use onbeforeunload?

If a user closes out of Internet Explorer by using the X in the top right corner, how can I prompt the user and ask them if they want to save or cancel the transaction?  If they want to save, I need to call a C# SaveValues() method, if they want to cancel, I need to call a C# RollBack() method.  Is this possible? Do I need a pop up?  I read dont use popups, because pop up blockers will cause them not to load.

Whats the best solution using 1.1, c#, javascript...

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I would use onbeforeunload with a confirm("Do you want to save your data?")

then if it returns true execute an Ajax call to the server side code to call save otherwise execute RollBack

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.