I am getting the following error:
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compile Error Message: CS1061: 'codebehind' does not contain a definition for 'btnSave_Click' and no extension method 'btnSave_Click' accepting a first argument of type 'codebehind' could be found (are you missing a using directive or an assembly reference?)
ASP button in the view:
<asp:Button ID="btnSave" runat="server" Text="Save" CssClass="btn btn-success btn-md" Width="100px" OnClick="btnSave_Click" />
Event registration in the code behind:
override protected void OnInit(EventArgs e)
{
btnSave.Click += new EventHandler(btnSave_Click);
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
OnClick Event:
private void btnSave_Click(object sender, EventArgs e)
{
//foo
}
Things I have tried:
- Renaming the onClick event in both view and codebehind
- Deleting onClick, going to the design tab, double click on the button to auto-generate a new event
- Changing auto-event wireup from false to true
Pertinent questions for reference:
- Does not contain a definition for and no extension method accepting a first argument of type could be found
- Error CS1061 “...Does Not Contain Definition and No Extension Method...accepting a first argument of type ” could be found
- "a" Does not contain a definition for"b" and no extension method ' b ' accepting a first argument of type
Please let me know if you need additional information.