‘ASP.business_aspx’ does not contain a definition for ‘submitSearchClick’ and no extension method ‘submitSearchClick’

I keep getting this error popping up every time I try to run a page on my website…

‘ASP.business_aspx’ does not contain a definition for ‘submitSearchClick’ and no extension method ‘submitSearchClick’ accepting a first argument of type ‘ASP.business_aspx’ could be found

This is the code I have in the page ‘business.aspx.cs’

protected void submitSearchClick(object sender, EventArgs e)
{
}

and this is the line that the error keeps pulling up…
<asp:Button ID="searchButton" text="Search" runat="server" onclick="submitSearchClick"/>

I am really confused at the moment, people have been telling me to change private to protected, but it is all ready protected, and I have searched the site for a viable answer but sadly, nothing has been found.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Let the mark up generate the event handler itself. Back up your event handler contents. Delete the on click event handler in the code behind and its attribute in the markup. Retype the on click attribute in the mark up but this time choose the create a new event option from Visual studio Intellisense.
This will create an event like this in the code behind.

protected void submitSearch_Click(object sender, EventArgs e)
   {


   }

This usually fixes a corrupt designer file.Clean and rebuild your solution and now the event will be wired to the button.

Alternatively , delete the onclick attribute in the mark up and its handler in code behind.Then right click the button in the designer, and on the onclick event, on its properties(accessed by clicking the lightning icon), regenerate the event handler.

Method 2

Is there a corresponding business.aspx.designer.cs file that is out of sync? Try changing a property on the control from within the designer. Need more information otherwise.

Method 3

Sometimes I get this error if I am trying to add a method to a control, while I am still running the project in debug mode. So the method doesn’t get added correctly in the webform.aspx.cs.

To correctly add it, select the method from the dropdown.

'ASP.business_aspx' does not contain a definition for 'submitSearchClick' and no extension method 'submitSearchClick'

Then choose Create Method.

'ASP.business_aspx' does not contain a definition for 'submitSearchClick' and no extension method 'submitSearchClick'


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x