This solution will help you use asp Text box and a Label to display the count of characters,
Add below code on your Default.aspx,
<asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine"
MaxLength="160" ></asp:TextBox>
<asp:Label ID="lblCharacters" runat="server"></asp:Label>
Add below javascript code on your default.aspx,
<script language="javascript" type="text/javascript">
function DisplayCount()
{
var length = document.getElementById('<%=txtComments.ClientID%>').value.length;
document.getElementById('<%=lblCharacters.ClientID%>').innerText = length;
}
</script>
Add following code on your Page_load event,
txtComments.Attributes.Add("onkeypress", "javascript:return DisplayCount();");
After adding above code, you can see the count on the label when you type in the textbox.
The .NET Framework allows developers to use the same set of skills to rapidly buid great applications for the web, windows, services and more.
Display Textbox count on a Label
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment