Tuesday, December 14, 2010

TextBoxCounter control by skmControls

In programming a textarea for a web application, I had the need to display to the user the amount of characters to go before the maximum length of the textarea was reached. I found a .NET library on line called skmControls2.dll that provides a textBoxCounter control. Documentation can be found at:

http://scottonwriting.net/sowblog/codeprojects.htm

Below is an example of the use of the control with some of its properties:

TextBoxCounter tbc = new TextBoxCounter();
tbc.TextBoxControlId = commentBox.ID;
tbc.TreatCarriageReturnsAsOneCharacter =
true;
tbc.MaxCharacterLength = 500;
tbc.DataFormatString =
" Characters entered = {1}.";
tbc.CssClass =
"CharacterNorm";
tbc.WarningPercentage = 95;
tbc.CssClassForWarning =
"CharacterWarn";