hi Everybody


I have added a button control to my page. when I start debugging an error message says

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

What is the reson for that. please Help me............

Recommended Answers

All 12 Replies

Can you post the code please?

Take a look here:

here

I believe it will help.

The button Login you have double clicked and it shows the code behind, then you removed that code. The solution is to go to the asp design on asp: Button ID = "btnLogin " runat = "Server"..... then you remove the code "onclick="btnLogin_Click", or else doble click the button and run the code

Hard to say wthout code, but do you have a method called 'btnLogin_Click' that is accesible?

Once you double click on the button, the code

Protected void btnLogin_click(objetc sender, EventsArgs e)

comes up same as on asp design, the code

onclick = "btnLogin_click"

also comes up. To simply solve your problem just double click the button then run your application

If you deleted the event handler method and no longer want it to run then what Mongz said will fix it.
If you have code that you want to run when the button is clicked then you hneed to ensure that the Method named in the event handler exists and is accessible to the code trying to run it. If it is in another class/file and doesnt have the correct access (public/protected/etc) it could be causing the error.

I had same issue and I figured out that there was problem with "script" tag in my aspx page. I had forgot to close the script tag. When I closed it ,error got resolved.

So this error either has to do with some incomplete tag that you have defined above "button" or with "Inherit" attribute that is at tha top of the page.Ensure to include correct namespace for page to inherit.

commented: hi,i have no incomplete tag and event name is same in both aspx page and aspx.cs file.still i am getting the same error +0

As mentioned earlier, you have onclick="" inside the asb:Button element on the page but no matching button function (button_onclick()) in your code behind. When compiling VS is looking for that function and not finding it.

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

Source Error:

Line 94: </td>
Line 95: <td align="left">
Line 96: <asp:TextBox ID="txtName" runat="server" meta:resourcekey="txtNameResource1" OnTextChanged="txtName_TextChanged"></asp:TextBox>
Line 97: </td>
Line 98: </tr>

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

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

somebody suggest me how to resolve the above error..event name in .aspx and aspx.cs is the same yet i am getting this error

Best advice is to recreate the server-side control and set all properties, double click to create DEFAULT event handler or in the Properties window, click the Event icon and search for the event you want to implement and double click on it...for HTML control, set the onClick property with the Javascript or Server-side function is running at server...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.