Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a webpage and on logout i need to enter the logout time to databse..i have done till that my problem is when user closes window i can't enter the value to database. . i tried window .onbeforeunload burt am not able to call the button click event inside that . Any Idea???
Posted
Updated 26-May-14 18:36pm
v2
Comments
Kornfeld Eliyahu Peter 26-May-14 5:50am    
Use ajax to call some server side method to record close event's time/date...
gggustafson 26-May-14 13:08pm    
Follow Kornfeld Eliyahu Peter suggestion. You might want to place the clean up code in an OnFormClosed event handler.
ZurdoDev 26-May-14 21:35pm    
You can do what Kornfeld suggested but there is no guarantee it will work. Trying to keep track of users that are currently logged in in ASP.Net is not a good idea.
HK33 27-May-14 2:53am    
I have to keep track of the user name and log in time..:)
ZurdoDev 27-May-14 7:00am    
In ASP.Net, it won't be guaranteed accurate. The web is a disconnected medium. They could force their browser closed through task manager and your code can't catch that. They could lose power and you can't catch that. Usually it's more work than it's worth.

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