TextBox Count And Display The Number Of Character Entered In Asp.Net C#

Count And Display The Nvlumber Of Character in TextBox


If Entered Character Or Numbers In TextBox  Count The Total Values Display Using Asp.Net C#.


DEMO





HTML CODING

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       
        <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" Height="25px" OnTextChanged="TextBox1_TextChanged" Width="200px"></asp:TextBox>
       
        <asp:Label ID="lblDisplayCount" runat="server" ForeColor="#CC3300" Height="25px" Width="150px"></asp:Label>
       
    </div>
    </form>
</body>
</html>

                             
                         C# CODING



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
       
     lblDisplayCount.Text ="COUNT ="+" "+TextBox1.Text.Count().ToString();

    }

}



First - Add New Form - Select TextBox & Label - TextBox Property Set AutoPostBack =True






Next - Add Label  - Change Id Values







Double Click - TextBox - Write Coding







Next - Run[F5] The Program - Enter Character or Number  Display Count Vlaues 


OUTPUT








0 comments:

Post a Comment