Reverse order of operations for OnClick and OnClientClick?
<p>I have some simple javascript that I'd like to run when a button is clicked, but I also want some postback action to occur on the server.  The logical code for this looks like this:</p>

<pre><code>&lt;asp:Button ID="btnOK" runat="server" Text="Save Changes" OnClientClick="UpdateParent();" OnClick="btnOK_Click" /&gt;
&lt;asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="window.close();" /&gt;

&lt;script language="javascript" type="text/javascript"&gt;
    function UpdateParent()
    {
    window.opener.document.location.reload(true); // or should we postback instead?
    window.close();  
    }
&lt;/script&gt;
</code></pre>

<p>Basically, a popup window should refresh its parent and then close itself.  However... if I call window.close(), the postback does not occur and the button handler is not called.  But obviously OnClientClick is called before the postback happens.  Am I going to have to emit this javascript in the button handler and run it when the page loads after postback?  If so, what is the <strong>proper</strong> way to do this these days for ASP.NET 2.0?</p>

<p>It's a shame that the code above doesn't work as it's elegantly simple and straightforward.</p>
