C#, ASP.NET, JS
I have this pop up opened where employees work on different clients.
Once they are done they click on a button and a few proceses run before actually closing the pop up window.
What I want to achieve is the same thing when they hit the X top right button of the screen.
I’ve tried this:
.aspx.
window.onclose = closePage;
.js.
function closePage() {
__doPostBack('XXXX', '');
}
.cs
//In Page_Load
if (Request["__EVENTTARGET"] == "XXXX")
{
//desired code.
}
It’s definetely not firing.
Any suggestions?
ASP.net runs at server level and doesn’t inherently “know” when the site is closed by the user. To achieve what you want you need to use ASP.NET Ajax.
There is a good article here;
http://stephenwalther.com/archive/2008/03/07/asp-net-ajax-in-depth-application-events.aspx