Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
System.Text.StringBuilder jScriptStr2 = new System.Text.StringBuilder ();
jScriptStr2.Append ("<script language=javascript>");
jScriptStr2.Append ("function limitText (textObj, maxCharacters){");
jScriptStr2.Append ("if (textObj.innerText.length >= maxCharacters){");
jScriptStr2.Append ("if ((event.keyCode >= 32 && event.keyCode <= 126) || (event.keyCode >= 128 && event.keyCode <= 254)){");
jScriptStr2.Append ("event.returnValue = false;");
jScriptStr2.Append ("}}}</script>");
Page.RegisterStartupScript ("textLimiter", jScriptStr2.ToString ());
<asp:TextBox TextMode="MultiLine" OnKeyDown="limitText (this, 255);" Rows="2" Width="175px" ID="txtDescription" Runat="server"/>
<script language=javascript>
function limitText (textObj, maxCharacters){
if(textObj.value.length<maxCharacters){
textObj.pref=textObj.value
}else{
textObj.value=textObj.pref;
}
}
</script>
<textarea onkeyup="return limitText(this,4)">
</textarea>
<textarea pref="" onkeyup="limitText(this,40)">
</textarea>
int maxChars = 4000;
string adjustedText;
if(this.tbTextArea.Text.Trim().Length > maxChars){
adjustedText = this.tbTextArea.SubString(0, maxChars);
}else{
adjustedText = this.tbTextArea.Text.Trim();
}