C# · 12月 25, 2021

c# – CS1061:编译错误消息


CS1061: ‘ASP.uilayer_test_aspx’ does not contain a deFinition for ‘lbl_Click’ and no extension method ‘lbl_Click’ accepting a first argument of type ‘ASP.uilayer_test_aspx’ Could be found (are you missing a using directive or an assembly reference?)


<asp:LinkButton ID=”lbl” runat=”server” OnClick=”lbl_Click”>LinkButton</asp:LinkButton>


<%@ Page Language=”C#” MasterPageFile=”~/UILayer/UI.Master” AutoEventWireup=”true” CodeBehind=”Test.aspx.cs” Inherits=”WebApp.UILayer.Test” Title=”Untitled Page” %>


namespace WebApp.UILayer{ public partial class Test : System.Web.UI.Page { private void lbl_Click(object sender,EventArgs e) { } }}解决方法 你必须使lbl_Click受保护而不是私有.