Set MaxLength property of asp.net multiline textbox
How to set MaxLength property of asp.net multiline textbox:
We all apprehend that we are able to set the utmost allowed characters in traditional textbox by setting its MaxLength property to desired range of characters. however same doesn’t work if the TextMode property of textbox is ready to Multiline.
When a Textbox is in SingleLine mode that is default TextMode , it gets rendered as AN input kind textbox and after we set its TextMode property to MultiLine, it gets rendered as a textarea. As we know, MaxLength property works just for input kind and not for textarea. however There square measure multiple ways in which to handle this victimization javascript, jquery or regular expression. however I got the straightforward answer to handle this while not victimization jquery or regularexpression.
HTML Source for How to set MaxLength property of asp.net
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> Set Max Length of multiline textbox </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset style="width:300px;">
<legend>Set max length of multiline textbox</legend>
<asp:TextBox ID="txtComments" runat="server" Width="300px" TextMode="MultiLine"MaxLength="60" placeholder="Max allowed:60 characters"></asp:TextBox>
</fieldset>
</div>
</form>
</body>
</html>
Asp.Net C# code to set max length of multiline textbox:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
txtComments.Attributes.Add("maxlength", txtComments.MaxLength.ToString());
}
}
Other Crystal Report related Post:
Here we give the list of Examples related to gridview:
- Show gridview Row Details.
- Templatefield in gridview
- Introduction of Asp.net grid view Control.
- Example of Templatefield in gridview .
- Example of DropDownList inside GridView
- Check box in ASP.NET GridView
- Ckeck box list example using javascript in grid.
- Check box in ASP.NET GridView
- Show grid view row details in to tooltip.
- How to Bind Grid view Form database.
- Show gridview Row Details And Give Example.
- Example of Template field.
- How to Bind Grid view Form database.
- Template field in asp.net grid view.
- Example of DropDownList inside GridView control
- Introduction of Asp.net grid view Control.
- Example of C# for Bind Data to asp.net Textbox inside gridview control
- Bind Data to asp.net textbox control in inside of gridview Using C# Example
Comments
Post a Comment