【发布时间】:2016-06-03 06:01:36
【问题描述】:
我正在尝试在 Visual Studio asp.net 上构建一个程序,但是每当我尝试单击带有 OnClick 事件的按钮时,我都会收到以下错误:
"CS1061: 'ASP.test_aspx' 不包含 'buttonClick' 的定义,并且找不到接受类型为 'ASP.test_aspx' 的第一个参数的扩展方法 'buttonClick'(您是否缺少 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>
这是我的代码:
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";
}
}
}
请保持解释尽可能简单,因为我是编码新手。感谢您的任何帮助。 :)
【问题讨论】: