i have added a linkbutton to my page and get error when debugging says:
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?)
.aspx contains :
<asp:LinkButton ID="lbl" runat="server" OnClick="lbl_Click">LinkButton</asp:LinkButton>
page diretive :
<%@ Page Language="C#" MasterPageFile="~/UILayer/UI.Master" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="WebApp.UILayer.Test" Title="Untitled Page" %>
.cs contains :
namespace WebApp.UILayer
{
public partial class Test : System.Web.UI.Page
{
private void lbl_Click(object sender, EventArgs e)
{
}
}
}
You have to make lbl_Click
protected and not private.
The reason for this is that an own class, called like ASP.uilayer_test_aspx
is created from the aspx source. This class inherits from your Test
class. Private methods are not visible to child classes, so it has to be protected.
Because you have set the click handler lbl_Click
modifier as private
, you have to set it as Protected
OR Public
. Since the aspx file inherited the cs class, and private member can't be accessed.
This
private void lbl_Click(object sender, EventArgs e)
should be like..
protected void lbl_Click(object sender, EventArgs e)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With