title: ASP.Net double-click problem
body: <p>having a slight problem with an ASP.net page of mine. If a user were to double click on a "submit" button it will write to the database twice (i.e. carry out the 'onclick' method on the imagebutton twice)</p>
  
  <p>How can I make it so that if a user clicks on the imagebutton, just the imagebutton is disabled?</p>
  
  <p>I've tried:</p>
  
  <pre><code>&lt;asp:ImageButton 
       runat="server" 
       ID="VerifyStepContinue" 
       ImageUrl=image src 
       ToolTip="Go" 
       TabIndex="98" 
       CausesValidation="true" 
       OnClick="methodName" 
       OnClientClick="this.disabled = true;" /&gt;
  </code></pre>
  
  <p>But this OnClientClick property completely stops the page from being submitted! Any help?</p>
  
  <p>Sorry, yes, I do have Validation controls... hence the icky problem.</p>
  
  <hr>
  
  <p>Working on this still, up to this point now:</p>
  
  <p>ASP code:</p>
  
  <pre><code> &lt;asp:TextBox ID="hidToken" runat="server" Visible="False" Enabled="False"&gt;&lt;/asp:TextBox&gt;
   ...
   &lt;asp:ImageButton runat="server" ID="InputStepContinue" Name="InputStepContinue" ImageUrl="imagesrc" ToolTip="Go" TabIndex="98" CausesValidation="true" OnClick="SubmitMethod" OnClientClick="document.getElementById('InputStepContinue').style.visibility='hidden';" /&gt;
  </code></pre>
  
  <p>C# code:</p>
  
  <pre><code>         private Random
      random = new Random();
  
  
      protected void Page_Load(object sender, EventArgs e)
      {
          //Use a Token to make sure it has only been clicked once.
          if (Page.IsPostBack)
          {
              if (double.Parse(hidToken.Text) == ((double)Session["NextToken"]))
              {
                  InputMethod();
              }
              else
              {
                  // double click
              }
          }
  
          double next = random.Next();
  
          hidToken.Text = next + "";
          Session["NextToken"] = next;
  </code></pre>
  
  <p>Actually... this nearly works. The double click problem is pretty much fixed (yay!) The image still isn't hidden though.</p>