Reputation: 4137
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()?
Upvotes: 2
Views: 389
Reputation: 4137
function clickclosebtn() {
if (window.event.clientX < 0 || window.event.clientY < 0)
{
document.getElementById("<%= btnClose.ClientID %>").click();
}
}
Upvotes: 0
Reputation: 245429
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.
Upvotes: 1