Try this, the max len in this example is 10:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default23.aspx.cs" Inherits="Default23" %>
<!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 id="Head1" runat="server">
<title></title>
<script type="text/javascript">
function enforceMaxLen(field, maxlen) {
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"
onkeydown="enforceMaxLen(TextBox1, 10);"
onkeyup="enforceMaxLen(TextBox1, 10);"
Style="height: 250px; width: 300px" TextMode="MultiLine"></asp:TextBox>
</form>
</body>
</html>
It works even if you try to copy and paste more than the maxlen.