Set max length of MultiLine TextBox in ASP.Net

Category > ASP.NET || Published on : Tuesday, January 26, 2016 || Views: 8097 || Set max length of MultiLine TextBox in ASP.Net


Introduction

Here Pawan Kumar will explain how to Set max length of MultiLine TextBox in ASP.Net

Description

In previous post I have explained How to rotating image with ASP.NET 4.0 and C# with example, How to turn off submit button when it pressed in ASP.Net, Code Snippets - Sending SMS through ASP.NET, Cascading dropdown in ASP.NET using JQuery Http Handler, How to add current copyright year in ASP.NET, How to avoid a form from double submission using asp.net, and many more articles.

Now I will explain How to Set max length of MultiLine TextBox in ASP.Net

So follow the steps to learn Set max length of MultiLine TextBox in ASP.Net

Javascript Code:-

<script type="text/javascript">
     function Check(textBox, maxLength) {
          if (textBox.value.length > maxLength) {
               alert("Max characters allowed are " + maxLength);
               textBox.value = textBox.value.substr(0, maxLength);
          }
     }
</script>

ASP.Net Code:-

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" 
onKeyUp="javascript:Check(this, 100);" onChange="javascript:Check(this, 100);" />

 

Conclusion:

So, In this tutorial we have learned, Set max length of MultiLine TextBox in ASP.Net