skip to Main Content

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


  1. Chosen as BEST ANSWER

    The problem was on the first line of the code.

     <%@ Page Title="" Language="C#" MasterPageFile="~/HomeMaster.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="WebForm.Login" %>
    

    I just change the CodeBehind to CodeFile then it worked fine for me.

    <%@ Page Title="" Language="C#" MasterPageFile="~/HomeMaster.Master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="WebForm.Login" %>
    

  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search