Christian is right. I think this
JQuery link provides what you want. Below is the code I tried (It worked):
<script type="text/javascript" src="jquery-1.6.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" language="javascript" >
$(document).ready(function() {
$("#txtSignature").keydown(function(event) {
var labelValue = parseInt($("#lblCharacters").html());
if (isNaN(labelValue))
labelValue = 0;
if (event.keyCode == 8 || event.keyCode == 46) {
$("#lblCharacters").html(labelValue - 1);
}
else {
$("#lblCharacters").html(labelValue + 1);
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtSignature" runat="server" TextMode = "MultiLine"
MaxLength="160" Enabled = "true" ></asp:TextBox>
<asp:Label ID="lblCharacters" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Note:
1. You have to put your logic to handle count going negative.
2. You have to handle when cursor is at left end and "backspace" is pressed.
2. You have to handle when cursor is at right end and "delete" is pressed.
I could have done this but I leave it to you.