Tutorial :event for the closingof the browser



Question:

i am having a asp.net and c#.net application and i have a page gridview.aspx which has a button "close".

when a person closes the browser page by clicking the close icon in the top right of the browser i want to perform the click event of the "close" button,

do we have any event beforebrowserclose()?


Solution:1

No.

WebForms applications use PostBacks to fire off Events. Since the browser doesn't do a PostBack before it closes, there's no way to wire an Event for that.

Unfortunately there's not even a reliable, cross-browser way to accomplish this in Javascript either.


Solution:2

function clickclosebtn() {

        if (window.event.clientX < 0 || window.event.clientY < 0)       {            document.getElementById("<%= btnClose.ClientID %>").click();       }        }  


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »