<script type="text/javascript"> function maxLength(field,maxChars) { if(field.value.length >= maxChars) { event.returnValue = false; alert("more than " + maxChars + " chars"); field.value = field.value.substring(0, maxChars); return false; } } </script>
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" onkeydown="return maxLength(this,'50');"></asp:TextBox>