DotCat

喜欢技术,喜欢简单,喜欢猫

导航

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端的验证肯定跑不掉的.

posted on 2006-01-09 11:04  DotCat  阅读(1634)  评论(1)    收藏  举报