<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MexLength.aspx.cs" Inherits="MexLength" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Maximum length counter</title>
<script language="JavaScript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
</script>
</head>
<body>
<form id="Form1" name="myform" runat="server">
<asp:TextBox ID="TextBoxMessage" runat="server" TextMode="MultiLine" Height="60px" onkeydown="textCounter(TextBoxMessage,LengthCount,25)" onkeyup="textCounter(TextBoxMessage,LengthCount,25)" ></asp:TextBox>
<input readonly type="text" name="LengthCount" size="3" maxlength="3" value="25">
</form>
</body>
</html>