开发者

Insert Data To Database When We Try To Close The Browse

开发者 https://www.devze.com 2023-03-21 10:31 出处:网络
I am trying to find a way to catch browser close event and call a server side code for database entry.

I am trying to find a way to catch browser close event and call a server side code for database entry.

I have tried Javascript for window.onbeforeunload and body.onunload but unload event is fired every time the page navigates.

I need to catch only browser close event.

I am using asp.net with C# and my page have a ma开发者_如何学Goster page.


Just use the code in one of these answers to call a function in your code-behind (that writes to DB)

Calling ASP.NET Code Behind function from JavaScript

Also, you can do client-side postbacks, explained on MSDN here

0

精彩评论

暂无评论...
验证码 换一张
取 消