Introduction
This is a tutorial on how to call a server-side ASP.NET method from a client-side JavaScript method.
If you are wondering when that could become useful, imagine the following scenario:
A Web Application having an implemented authentication system.
Users log in with their username and password.
At any point the user is able to log out by clicking on the respective “Log Out” button.
On the server-side, the log out action would trigger a cleaning up process of user’s temp data.
However, the user instead of clicking on the “Log Out” button, may simply close the browser window. Now since HTTP is a stateless protocol, the server-side cannot directly detect the user’s action. Therefore the client-side (browser) would have to notify the server that the user is closing the window.
A solution to this problem would be to call a JavaScript function when the client-side “onUnload” event…
View original post 397 more words