You are looking for the TextChanged
event.
Write the method:
protected void textBox1_TextChanged(object sender, EventArgs e)
{
if(textBox1.Text.Length >= 8)
{
// do things
}
}
Then add it as a listener:
textBox1.TextChanged += this.TextBox1_TextChanged;
(If you’re using the Visual Studio designer you can select the TextBox
, go to the Properties window, click the Events button, and double click the TextChanged
event to automatically create and add the method)
solved Automatically check textbox length c# [closed]