views:

3203

answers:

2

I have an ASP.NET (C#) page with some 3rd party controls, some ajaxy stuff and some normal ASP.NET Button controls.

The Button click events do not fire when clicked.

Double-clicking the button in design mode in VS 2008 switches to the code-behind but doesn't create the event handler.

Creating the event handler manually doesn't help.

The whole page is too big to include here, but this is the top bit:

<%@ Page Language="C#" MasterPageFile="~/basewidepage2.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="CompanyCompliance.aspx.cs" Inherits="CompanyCompliancePage" Title="3DSS" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc2" %>
<%@ Register Src="usercontrols/CalendarEx.ascx" TagName="CalendarEx" TagPrefix="uc2" %>
<%@ MasterType VirtualPath="~/basewidepage2.master" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceholder1" runat="Server">

    <script type="text/javascript">
         // a bunch of function declarations
    </script>

...and my button declaration on the page:

<asp:Button ID="LicenseCsvButton" runat="server" Text="Export to CSV" OnClick="LicenseCsvButton_Click" />

...and the code-behind:

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");
}

Any ideas? could it be the ajax or something? Maybe the 3rd party "obout" grid control?

Update:
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.

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.

+1  A: 

Change

CodeFile="CompanyCompliance.aspx.cs"

to

CodeBehind="CompanyCompliance.aspx.cs"

Related question: http://stackoverflow.com/questions/73022/codefile-vs-codebehind

TJB
Thanks, but it doesn't compile, I get "Could not load type 'CompanyCompliancePage'. CompanyCompliance.aspx 1". Could this be because it's in vs 2008 (asp.net 3.5) and so using partial classes for the code behind page?
MGOwen
Is there a .designer.cs class?Also make sure that Inherits="CompanyCompliancePage" matches your classname, you may need to fully qualify it...If all else fails, rename your current page, then do Add > New Item > Web Content Form > Name it 'CompanyCompliance' make sure you can just drop in a button and invoke the onclick handler, once that works then copy over as much as the markup / code as you can from the existing one.
TJB
I thought designer.cs and CodeBehind="" were mainly just for older versions of .net... that's what your link seems to be saying. Is that not correct?
MGOwen
Are you using ASP.net web forms (traditional) or ASP.net mvc? the latest version of Web Froms still uses code behind last I checked... I just came across that link and thought it might be useful, but I think its more complicated than what you're saying
TJB
No, web forms has used codefile instead of codebehind since 2005. Thanks anyway.
MGOwen
+1  A: 

The inherits directive seems to point to a non-existant type.

Take a look in the code behind file of the CompanyCompliance page - ("CompanyCompliance.aspx.cs").

you should find the correct namespace and something like "public partial class xxx" where xxx is the name of the class which should correspond with your inherits directive. maybe you have to fully qualify the name as TJB already stated.

360Airwalk
Thanks, but checked all this before posting question, the type exists.
MGOwen