我试图在visual studio asp.net上构建一个程序,但每当我尝试单击一个带有OnClick事件的按钮时,我都会收到以下错误:
"CS1061:'ASP.test_aspx'不包含'buttonClick'的定义,并且没有扩展方法'buttonClick'接受类型'ASP.test_aspx'的第一个参数可以找到(你是否缺少using指令或汇编引用? )"
这是我的HTML供参考:
<%@ 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>
Run Code Online (Sandbox Code Playgroud)
这是我的代码背后:
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"; …Run Code Online (Sandbox Code Playgroud)