ASP.NET TextBox.MultiLine maxlength

According to msdn in ASP.NET you can not use the MaxLength property textbox with multiline mode. But I needed in my current application. So I search google and other search engines and finally some solutions. I just compile all the solutions in a single post.
Solution No. 1 to
ASP.NET TextBox.MultiLine MaxLength

Add the following javascript

Function Count (text, length)



{



var MaxLength = new Number (long); / / Change number to your max length.



if (document.getElementById ('<%= textBox.ClientID %>'). value.length> MaxLength) {



text.value.substring text.value = (0, MaxLength);



alert ("Only" + length + "characters");



}




Where "textBox" is the ID text box asp.
Also add the following event in your textbox.

onkeyup = "javascript: Count (this, 200);" onChange = "javascript: Count (this, 200);"


The code will look like a textbox



Servers






Solution No. 2 to


ASP.NET TextBox.MultiLine MaxLength

Another way to achieve this is regular expressions. You can add the following regular expression to validate a text box in asp.

Postingan populer dari blog ini

vb6 msflexgrid

Tutorial Visual Basic 6.0 : Listbox in VB6

Select Single Cell in MSHFlexgrid