Hi Mates,
if you are using a TextBox Server Control and have modified the TextMode property to MultiLine and have it's MaxLength=200 for example it will simply not work.. and when you run your application no matter what is the browser that you are using, the TextBox Control will completly ignore the MaxLength property.
And the reason for that is the fact that MultiLine TextBox Controls renderd into TextArea which is not aware of the MaxLength so it won't work.
Okay, so how can you have your validation on that TextBox and avoid mass/bulk inserting of thousants of charachter that will probaply not only mess with your data but will crash your application as well.
So the solution rely on the use of JavaScript to validate the input on the client side.. as using the TextChange server event will be a performance killer.
<script type="text/javascript" language="javascript">
function ValidateTextArea(TextArea, MaxLength)
{
if (TextArea.value.length > MaxLength)
TextArea.value = TextArea.value.substring(0, MaxLength);
}
</script>
and on the Page_Load server event handler wire this function to fire when KeyDown event occur on the TextBos Control.
MyMultiLineTextBox.Attributes.Add("onkeydown", "ValidateTextArea(MyMultiLineTextBox,250)");
This will allow only a 250 charachter to be written on that TextBox.