title: Fire jQuery event before postback occurs - asp.net
body: <p>I've been looking for a method of adding a jQuery event to a button which once clicked will fire the event followed by the asp postback.</p>
  
  <p>Adding the event is easy enough the issue however is delaying the asp postback temporarily.</p>
  
  <p>Asp Code (Events added in C#):</p>
  
  <pre><code>&lt;input runat="server" ClientIDMode="static "id="cancelButton"&gt;
  </code></pre>
  
  <p>JQuery Code:</p>
  
  <pre><code>var cancelBtn = jQuery('#cancelButton');
  
  cancelBtn.click(function (e) {
      e.preventDefault();
  
      var cancelBtnEvent = cancelBtn[0].click;
  
      jQuery(pnl).animate({
          height: 200
      }, 300, 'swing', function () {
          cancelBtnEvent();
      });
  }); 
  </code></pre>
  
  <p>In the code above I am adding a click event to the button, 'cancelBtn' is an input[type="button"]. The event will stop the defaults, save the click function to call later, do some animation then call the click function. However this fails with the error invalid object call.</p>
  
  <p>So my question:</p>
  
  <p>How should this be done? or Can my solution be fixed?</p>
  
  <p>Thanks </p>