title: Disable buttons after click until post back of ascx control using javascript
body: <p>The page works as expected, disables the buttons and shows my loading indicator but the OnClick event is never called. I am relatively inexperienced with Javascript and I cannot seem to find an answer as to why this doesn't work.</p>
  
  <p>I expect that once the Disable() method occurs and returns true it will call the OnClick method, which will cause a post back and automatically re-enable the buttons.</p>
  
  <p>Perhaps I am going at this all wrong, I appreciate your help.</p>
  
  <pre><code>&lt;%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %&gt;
  &lt;%@ Control Language="c#" Inherits="MyControl"
  Codebehind="ThisControl.ascx.cs"%&gt;
  
  &lt;div class="Form" style="width: 100%"&gt;
  
    &lt;img id="imgLoading" src="images/GridImages/spinner.gif" style="display:none" alt="loading..." /&gt;
  
    &lt;ol&gt;
      &lt;li&gt;
          &lt;asp:Button ID="FirstButton" CssClass="btn" runat="server" Text="First Press Me"
              OnClick="First_Click" OnClientClick="this.value='Please Wait...'; needToConfirm=false; return Disable(); "/&gt;
          &lt;span&gt;
              &lt;asp:Button ID="SecondButton" CssClass="btn" runat="server" Text="Second Press Me"
                  OnClick="Second_Click" OnClientClick="this.value='Please Wait...'; needToConfirm=false; return Disable(); "/&gt;
          &lt;/span&gt; 
      &lt;/li&gt;
    &lt;/ol&gt;
  
    &lt;script type="text/javascript"&gt;
      function Disable() {
          document.getElementById('&lt;%=FirstButton.ClientID %&gt;').disabled = true;
          document.getElementById('&lt;%=SecondButton.ClientID %&gt;').disabled = true;
          setTimeout('UpdateImg()', 0);
          return true;
      }
      function UpdateImg() {
          $('#imgLoading').show();
          var img = document.getElementById('imgLoading');
          img.src = 'images/GridImages/spinner.gif';
      }
    &lt;/script&gt;
  
  &lt;/div&gt;
  </code></pre>