I get a compiler error message: CS1061: when I click the report button

I tried adding files to update the application to create new excel reports in my web application hosted on IIS 7, but I get the error below when I click to create in the application

Compilation error
Description: An error occurred while compiling the resource required to service this request. Review the specific error data below and modify the source code accordingly.

Compiler Error Message:

CS1061:

'ASP.reportmonthlyreturns_aspx' does not contain a definition for 'btnGenerator_Click' and no extension method 'btnGenerator_Click' accepting a first argument of type 'ASP.reportmonthlyreturns_aspx' could be found (are you missing a using directive or an assembly reference?) 

Source Error:

 Line 36: SelectCommand="SELECT distinct year(departure_berth) as year FROM va_voyage_master_tb"> Line 37: </asp:SqlDataSource> Line 38: <asp:Button ID="btnGenerator" runat="server" Text="Generate Report" Line 39: class="button round blue image-right ic-right-arrow" onclick="btnGenerator_Click" Line 40: /> Source File: c:\inetpub\wwwroot\VoyageApplication\ReportMonthlyReturns.aspx Line: 38 
+4
source share
1 answer

It looks like your markup page (.aspx) contains a link to an event that does not exist in your code behind the page (.cs).

Check the enclosure in the OnClick property declaration. It should be Pascal with the cover: "OnClick".

Based on your markup,

 <asp:Button ID="btnGenerator" runat="server" OnClick="btnGenerator_Click" /> 

your code should contain something like that:

 protected void btnGenerator_Click(object sender, EventArgs e) { // logic here } 

Is it likely that you have changed the OnClick event property in your markup or code? These two must match.

+3
source

Source: https://habr.com/ru/post/1445551/


All Articles