ASP.Net TextBox TextMode – SingleLine, Password and MultiLine

TextBox TextMode in ASP.Net

In this asp.net tutorial we will discuss about TextBox control TextMode property in detail.
We can use textbox control as a single line text input or as a multi line text input or as a password text input control. A by default textbox control is a single line textbox, we can change programmatically textbox mode from single line to multi line or password by writting c# code.

In ASP.Net 4.5 Microsoft has added new textbox textmode feature. In previous old ASP.Net version TextBox control had only three properties for TextMode.

  • SingleLine
  • MultiLine
  • Password

Microsoft added more features with version ASP.Net 4.5 for TextBox TextMode property.

TextMode Description
SingleLine It is used to display single line textbox. for single line value.
MultiLine It is used to display multi line textbox. textarea for address field.
Password It is used to display password textbox. shows password * character.
Color It is used to set color picker.
Date It is used for date entries, enter only dates.
DateTime It is used for datetime entries.
DateTimeLocal It is used for datetime entries with local time zome.
Email It is used for email address entries.
Month It is used for month and year entries.
Number It is used for numbers entries. allow only numeric values.
Range It is used for range between two numbers.
Search It is used for search text field.
Phone It is used for phone number entries.
Time It is used for time entries.
Url It is used for website url entries.
Week It is used for week and year entries.
Below figure shows the list of TextMode properties of TextBox control. we can set manually each property on textbox by selecting TextMode from list. we can also change TextMode dynamically by doing programming in c#.
TextBox TextMode property in ASP.Net
TextBox TextMode property in ASP.Net

SingleLine, MultiLine and Password TextMode Example

In this asp.net TextBox TextMode example we will change TextMode property programmatically by using c#. Here we have taken three button control one for SingleLine, second for MultiLine and Password mode.

TextBox TextMode property in ASP.Net
TextBox TextMode property in ASP.Net

C# code for above example

Example of TextBox TextMode Properties

Now, we use all TextMode properties of TextBox in this asp.net example as show in above list.

Below example shows the TextMode property Color, Email, Number, Url, Search and Range.

Html code for .aspx page are :

TextBox TextMode Example ASP.Net
TextBox TextMode Example ASP.Net

C# code above example

Here, we have two button one for Color property and other for Range property.

Example : Date, DateTime, DateTimeLocal, Month, Time, Week

TextBox TextMode Example ASP.Net
TextBox TextMode Example ASP.Net

Leave a Reply

Your email address will not be published. Required fields are marked *