user1490374
user1490374

Reputation: 65

Character and message count for ASP.NET

anyone have any idea how to increase a label to 2(or more) messages whenever there are 160 characters or more in a text box?

Upvotes: 1

Views: 551

Answers (1)

Prem Singh
Prem Singh

Reputation: 1035

Create an Event to change the text in the textbox, calculate number of characters there. Then check for the required characters to reach the limit, and increase the label text value as shown below,

private void txtSearchMember_TextChanged(object sender, EventArgs e)
    {
       if (txtSearchMember.Text.Length >= 160)
        {
                lblMessageCount.Text = 1; // Increase count with simple maths
        }
    }

Upvotes: 3

Related Questions