I have a script block which hooks to a window.onUnload event listed below (Thanks to David Gilmore for the help with that). The function works great, but I want to use the same event to call a function in a Server Side Script Library. Is that possible, and if so, how do you make the call?
The function I’m calling is named closeConnection(), which closes a SQL connection and sets a sessionScope variable to null.
I’m not aware of how to call server-side code in an onunload event. I’m currently working on getting the onunload event to set a field, then “click” a button. That button is a normal UI element that the user can click. Normal buttons can run both client and server-side code, so the button does the server work.
It’s inelegant, at best, but it’s all I could think of. If someone else has a cleaner solution I’d be happy to hear it.