Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If user trying to close browser via windows task manager.. i need to perform some action before kill that web page or browser.. How can we achieve it using asp.net with VB.
with thanks,
Gopinath Ganesan
Posted

1 solution

You can't with VB. VB and ASP.Net run on the server side so it has no way of knowing that a client has closed its browser. You can do some things on client side using the window.close() event in javascript.

JavaScript
// wire up event to fire when closing window
window.onbeforeunload = WindowIsClosing;

function WindowIsClosing() {
  if (window.event.clientX < 0 || window.event.clientY < 0) {
// do your own logic, but for example:
        if (!Validate()) {
            var msg = 'Test';
            event.returnValue = msg;
            return msg;
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900