Compilation Error
Description: 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.
CS1061: ‘signup_aspx’ does not contain a definition for ‘Button2_Click’ and no accessible extension method ‘Button2_Click’ accepting a first argument of type ‘signup_aspx’ could be found (are you missing a using directive or an assembly reference?)
Source Error:
<div class="form-group">
<div class="text-center">
<asp:Button ID="Button2" class="btn btn-primary" runat="server" Text="Sign Up" OnClick="Button2_Click" />
</div>
.aspx.cs code:
protected void Button2_Click(object sender, EventArgs e)
{
try
{
Response.Redirect("home.aspx");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
2
Answers
The problem was on the first line of the code.
I just change the
CodeBehind
toCodeFile
then it worked fine for me.You can remove the onclick code,i.e cut and paste in .txt file
the re-create the onclick event to the button in the design view ,after which you re-enter the code fron the .txt file into the code window onclick event.