Close Button (right top X) to act similar to control?
<p>C#, ASP.NET, JS</p>

<p>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.</p>

<p>What I want to achieve is the same thing when they hit the X top right button of the screen.</p>

<p>I've tried this:</p>

<p>.aspx. </p>

<pre><code>window.onclose = closePage;
</code></pre>

<p>.js. </p>

<pre><code>function closePage() { 
__doPostBack('XXXX', '');
}
</code></pre>

<p>.cs</p>

<pre><code>//In Page_Load
if (Request["__EVENTTARGET"] == "XXXX")
       {
           //desired code.
       }
</code></pre>

<p>It's definetely not firing.</p>

<p>Any suggestions?</p>
