c# - ASP.NET button on a web control has click event, but isn't recognized by control -


for old asp.net project working on, have user control button...

<%@ control language="c#" autoeventwireup="true" codebehind="mycontrol.ascx.cs" inherits="mynamespace.mycontrol" targetschema="http://schemas.microsoft.com/intellisense/ie5" %>  <!-- snip: unrelated html tags... --> <asp:button id="btsubmit" onclick="btsubmit_click" runat="server" style="font-weight: bold; color: black" tabindex="32" text="view"></asp:button> 

since upgrading .net 4.0, whatever platform try run on, following error:

compiler error message: cs1061: 'asp.mycontrol_ascx' not contain definition 'btsubmit_click' , no extension method 'btsubmit_click' accepting first argument of type 'asp.mycontrol_ascx' found (are missing using directive or assembly reference?)

...yet in code behind:

// class defined partial, between mycontrol.ascx.cs , mycontrol.designer.ascx.cs public class mycontrol : usercontrol {     // defined in designer code...     protected button btsubmit;      // defined in main code behind...but defined.     protected void btsubmit_click(object sender, eventargs e)     {         // snip: functionality works.     } } 

i've tried following things resolve issue:

  1. ensuring markup valid
  2. ensuring c# code has no compilation errors.
  3. double-checked control razor tag ensure autoeventwireup true, , codebehind , inherits set.
  4. checked ensure button control isn't colliding button click event.
  5. re-associated button click event in design mode, per suggestion.

also of note: web project being deployed web server via teamcity. works correctly when ran locally through visual studio, fails on server.

question: causing compiler error? code looks right. can detect no flaw in it.

the resolution problem, oddly enough, build settings off! code is sane!

as tip, you'll want following steps, diagnostic measure:

  1. right-click solution, navigate properties
  2. expand configuration properties, click configuration.
  3. ensure libraries need build have build checkmark checked.

the reason failing because dlls didn't exist, because weren't built in first place; when project whole tried reference these non-existant dlls failed horribly above compilation error.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -