I have the following textbox in my ASP.net page:
<asp:TextBox OnTextChanged="maxchar" ID="txtName" Width="95%" runat="server"></asp:TextBox>
The following in my code-behind:
protected void maxchar(object sender, EventArgs e)
{
if (txtName.Text.Length > 25)
{
lblIsValid.Text = "only 25 characters allowed";
}
}
When I enter text in the textbox and exceed the 25 character nothing is displayed in the label. How can I fix it?