简体   繁体   中英

page 'analysis_aspx' does not contain a definition for 'Button1_Click' and no extension method 'Button1_Click

this is my error CS1061: 'analysis_aspx' does not contain a definition for 'Button1_Click' and no extension method 'Button1_Click' accepting a first argument of type 'analysis_aspx' could be found (are you missing a using directive or an assembly reference?)

my code in aspx file:

<asp:Button ID="Button1" CssClass="btn" runat="server" Text="Happy" Font-Bold="True" Font-Size="Medium" Height="40px" Width="100px" OnClick="Button1_Click" />

i have 3 buttons like this.

my codebehind that is .cs file is

protected void Button1_Click(object sender, EventArgs e)

i have seen some related questions but in most questions they are missing something so they got the error but for me i don,t know why i am getting this error .

someone can show me the right direction. Thanks In Advance

I had a similar issue , i changed all Button naming to new button say button1 to button2 and build and ran it worked. it may be looking at the same button 1 in another page ?

Try to delete that button. Clean and rebuild the code. Add a new button again. This should resolve the issue.

Please check if the button is added to the designer file of the aspx. This problem happens when the designer file is not refreshed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM