I try to create a program on visual studio asp.net, but whenever I try to click a button with an OnClick event, I get the following error:
"CS1061:" ASP.test_aspx "does not contain a definition for" buttonClick ", and the buttonClick extension method cannot be found that accepts the first argument of type" ASP.test_aspx "(do you miss the using directive or the assembly reference?)"
Here is my HTML for reference:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="MRAApplication.test" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button id="b1" Text="Submit" runat="server" OnClick="buttonClick" /> <asp:TextBox id="txt1" runat="server" /> </div> </form> </body> </html>
and here is my code:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace MRAApplication { public partial class test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } void buttonClick(Object sender, EventArgs e) { txt1.Text = "Text"; } } }
Please keep the explanations as simple as possible as I am new to coding. Thanks for any help. :)
Jago
source share