Click here to Skip to main content
15,942,847 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends , i work on a web project. I have a button on my page and works great. But new buttons don't work. Same code but doesn't work.

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.

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

in my .cs page :

public void Button2_Click(object sender, EventArgs e)


but still doesn't work.
Updated 1-Nov-17 23:30pm
Sandeep Mewara 11-May-12 5:17am    
How did you define your new buttons? Share the code snippet related to it.
kozmikadam 11-May-12 5:20am    

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Add" /> // Does work

<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" /> //Doesn't work.

1 solution

This error occurs when you try to call a method or access a class member that does not exist.
Details here: Compiler Error CS1061[^]

Make sure that the class in which you define your new button controls (where you defined their click events too, ex Button2 & Button2_Click click event) & the event method public void Button2_Click(object sender, EventArgs e) are in the same class scope.
Share this answer
kozmikadam 11-May-12 5:28am    
my .cs page :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace deneme.User
public partial class profile : System.Web.UI.Page

protected void Button1_Click(object sender, EventArgs e)


protected void Button2_Click(object sender, EventArgs e)



my .aspx page

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Add" />

<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" />

all the same. button1 works. any other buttons don't work.

Click event of button2 is Button2_Click
Sandeep Mewara 11-May-12 12:25pm    
Well, there is nothing wrong in it. I would suggest you to clear your cache or create a new project and try it there. It should work. Difficult to tell how it is corrupt or not working.
Member 11533374 15-Dec-15 18:50pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900