title: C# - ASP.NET Button click event not working
body: <p>I have an ASP.NET (C#) page with some 3rd party controls, some ajaxy stuff and some normal ASP.NET Button controls.</p>
  
  <p><strong>The Button click events do not fire when clicked.</strong></p>
  
  <p>Double-clicking the button in design mode in VS 2008 switches to the code-behind but doesn't create the event handler.</p>
  
  <p>Creating the event handler manually doesn't help.</p>
  
  <p>The whole page is too big to include here, but this is the top bit:</p>
  
  <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/basewidepage2.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="CompanyCompliance.aspx.cs" Inherits="CompanyCompliancePage" Title="3DSS" %&gt;
  
  &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %&gt;
  &lt;%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc2" %&gt;
  &lt;%@ Register Src="usercontrols/CalendarEx.ascx" TagName="CalendarEx" TagPrefix="uc2" %&gt;
  &lt;%@ MasterType VirtualPath="~/basewidepage2.master" %&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceholder1" runat="Server"&gt;
  
      &lt;script type="text/javascript"&gt;
           // a bunch of function declarations
      &lt;/script&gt;
  </code></pre>
  
  <p>...and my button declaration on the page:</p>
  
  <pre><code>&lt;asp:Button ID="LicenseCsvButton" runat="server" Text="Export to CSV" OnClick="LicenseCsvButton_Click" /&gt;
  </code></pre>
  
  <p>...and the code-behind:</p>
  
  <pre><code>protected void LicenseCsvButton_Click(object sender, EventArgs e)
  {
      // get data
      CompanyCompliance cc = new CompanyCompliance(Master.theCompany.ID);
      DataTable dt = cc.BusinessLicenses.Tables[0];
  
      // send to browser as download
      Tools.SendTableAsCsvToBrowser(Response, dt, "LicenseData");
  }
  </code></pre>
  
  <p>Any ideas? could it be the ajax or something? Maybe the 3rd party "obout" grid control?</p>
  
  <p><strong>Update:</strong><br>
  I did fix this a month or two ago, so I came back to this question to answer it for posterity but couldn't remember exactly how I fixed it! (Curse you, old age!) I had some limited success by replacing some of the ASP.NET AJAX controls with jQuery UI ones but I think the real solution was that one of the properties in the one of the  tags was pointing to a control that no longer existed.  </p>
  
  <p>If you're in this same situation, try that and let me know what works in the comments and I'll post the correct answer.</p>