CS1061: (are you missing a using directive or an assembly reference?

mark picture mark · Dec 26, 2014 · Viewed 17.6k times · Source

I am getting this error

CS1061:'ASP.dashboard_aspx' does not contain a definition for 'Button6_Click' and no extension method 'Button6_Click' accepting a first argument of type 'ASP.dashboard_aspx' could be found (are you missing a using directive or an assembly reference?)

When I run it on my development PC it works fine, however when I uploaded on the server it gives this error.

Source Error:

Line 252:
Line 253:                </td><td>
Line 254:<asp:Button ID="Button3" runat="server" BackColor="#FF9933"     ForeColor="White"   Height="30px" Text="Search" Width="129px" OnClick="Button3_Click" Visible="False" />
Line 255:                </td>
Line 256:            </tr>

My CS file :

<asp:Button ID="Button3" runat="server" BackColor="#FF9933" Font-Size="Large" ForeColor="White" Height="30px" OnClick="Button3_Click" Text="Search" Visible="False" Width="200px" />

Code Behind :

protected void Button3_Click(object sender, EventArgs e)
    {
        conn = new SqlConnection(strcon);
        conn.Open();
        DataTable dt = new DataTable();
        cmd = new SqlCommand("select * from AssignedProject  where under=@Projectid", conn);
        cmd.Parameters.AddWithValue("@Projectid", DropDownList2.Text);
        da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            Label16.Text = "View FTEs Details";
            GridView5.Visible = true;
            GridView2.Visible = false;
            GridView5.DataSource = dt;
            GridView5.DataBind();

        }
        else
        {
            Label16.Text = " On Going Project";
            loadGV();
        }
        conn.Close();
    }

I have tried to : 1. Clean and Rebuild 2. Recreate the button and event 3. Researched and they said to add Inherit tag at <@Page its already there. Nothing seems to be working . It confuses as it was running a day before on the server too. Just added this button and dropdownlist since then its not working.

Please let me know If I am missing anything. Thanks

Answer

Ravindra picture Ravindra · Dec 27, 2014

At Line Number 1061. You have another Button with Onclick="Button6_Click" and Protected void 'Button6_Click' is deleted from code behind.

Debugger not necessary point at exact error location.