Hi
I'm experimenting with classes in asp.net. I try to put an event into a new class, but this is the error i get: CS1061: 'webform1_aspx' does not contain a definition for 'TextBox1_TextChanged' and no accessible extension method 'TextBox1_TextChanged' accepting a first argument of type 'webform1_aspx' could be found.
Thanks for help.
V.
using System;
namespace test
{
public partial class WebForm1 : System.Web.UI.Page
{
public string a = "";
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Focus();
}
}
class Test
{
WebForm1 wb = new WebForm1();
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
wb.a = wb.TextBox1.Text;
wb.Label1.Text += wb.a;
}
}
}
aspx file
---------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test.WebForm1" %>
...
...

Pasang TamangRank #449 · 5.6K reputationPosted Dec 30, 2022, 8:40 AM EST
Hi,
Below code should be inside WebForm1 class
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
wb.a = wb.TextBox1.Text;
wb.Label1.Text += wb.a;
}
Regards,
Pasang
Pasang TamangRank #449 · 5.6K reputationPosted Dec 30, 2022, 8:48 AM EST
Please check below code
protected void Page_Load(object sender, EventArgs e) { TextBox1.Focus(); } protected void TextBox1_OnTextChanged(object sender, EventArgs e) { Label1.Text += TextBox1.Text; }Regards,
Pasang
Valerie MeunierRank #1,526 · 1K reputationPosted Dec 30, 2022, 9:50 AM EST
Thansk for replying, but if the code below is in the WebForm1 class, of course it will work. I'm trying to put an event (like TextBox1_TextChanged) into another class and to activate it from there.