Error even having the click method

Asked

Viewed 951 times

1

Please, can someone help me with a boring bug with ASP.NET? Next... I have a button:

<asp:Button ID="cadastra" CssClass="btn btn-success btn-lg" runat="server" Text="Cadastrar Cliente" onclick="cadastra_Click1" />

And I have the method cadastra_Click1

protected void cadastra_Click1(object sender, EventArgs e)
{
   Response.Write("<script>alert('clockado');</script>");
}

When I try to run the code the compiler brings me the following error:

CS1061: 'ASP.cadcliente_aspx' does not contain a definition for 'cadastra_Click1' and no 'cadastra_Click1' extension method accepts that a first argument of type 'ASP.cadcliente_aspx' is found (you are not using an Assembly guideline or reference?)

I don’t know what else to do.

1 answer

2


Try to delete the button and create again with the project stopped. If you add a button with the project running sometimes it does not add in designer.cs, and another, make sure you didn’t rename the page copy and paste and rename or something like that because the code may be pointed to an old source without the method.

On top of aspx has an excerpt that informs where the codebehind CodeBehind="SuaPagina.aspx.cs" the method must be in this file

  • It worked, but the error continued and I found where it was, it was in a class that had reference with the click event. Thanks for the help! @adrianolsk

Browser other questions tagged

You are not signed in. Login or sign up in order to post.