Asp.Net 中 TextBox的TextBoxMode为多行时MaxLength无效

MSDN上是这样说的.那怎么办呢?还好有javascript.
function textCounter(field, maxlimit)
{
 
if  (field.value.length  >  maxlimit)
  field.value 
=  field.value.substring( 0 , maxlimit);
}


textBox.TextMode  =  TextBoxMode.MultiLine;
textBox.Rows  
=   5 ;
textBox.Columns  
=   50 ;
textBox.Attributes.Add(
" onKeyDown " , " textCounter(this,800); " );
textBox.Attributes.Add(
" onKeyUp " , " textCounter(this,800); " );


当然server端的验证肯定跑不掉的.

你可能感兴趣的:(asp.net)