If its an ASP.NET button look at the OnClientClick property. You can set a JavaScript function in this (i.e. <asp:button OnClientClick="DoFunction()" runat="server">. It will run the JavaScript before completing the button post back.
If your using an html button, you just need to move your functionality into a JavaScript call and put it in the OnClick property. Hope that helps.