New TextMode Properties in ASP.NET 4.5

While working on an open source project called “Link Shortner“, I came to know about a new enumerations of Texbox server control under the property “TextMode”. So let’s discuss about it.

Basically it specifies the behaviour mode of the text box. The TextBoxMode enumeration represents the different display options for textbox server controls.

Note: ASP.NET 4.5 provides full HTML5 support.

e.g If the TextMode of the TextBox control is set to “Password”, then all characters entered in the TextBox control are masked and are not saved in view state.

Following is a list of all the available values for this property and short description in ASP.Net 4.5:

SingleLine Represents single-line entry mode
MultiLine Represents multiline entry mode
Password Represents password entry mode
Color Represents color entry mode
Date Represents date entry mode
DateTime Represents date-time entry mode
DateTimeLocal Represents local date-time entry mode
Email Represents email address entry mode
Month Represents month entry mode
Number Represents number entry mode
Range Represents numeric range entry mode
Search Represents search string entry mode
Phone Represents phone number entry mode
Time Represents time entry mode
Url Represents URL entry mode
Week Represents week entry mode

I request developers to explore the different properties on different browser.

Let’s see some textmode property values:

1. DateTimeLocal

<asp:TextBox ID="textBox1" runat="server" TextMode="DateTimeLocal"></asp:TextBox>

2. Email

<asp:TextBox ID="textBox" runat="server" TextMode="Email"></asp:TextBox>

If you see here, validation was automatically fired when I click on “Submit” button, because of the invalid email address.

3. Month

<asp:TextBox ID="textBox3" runat="server" TextMode="Month"></asp:TextBox>

4. Time

<asp:TextBox ID="textBox5" runat="server" TextMode="Time"></asp:TextBox>

5. Range

<asp:TextBox ID="textBox7" runat="server" TextMode="Range"></asp:TextBox>

6. URL

<asp:TextBox ID="textBox8" runat="server" TextMode="Url"></asp:TextBox>

If you observe here, validation was automatically fired when I click on “Submit” button, because of the ‘url’ is not a valid URL.

7. Week

<asp:TextBox ID="textBox6" runat="server" TextMode="Week"></asp:TextBox>

Hope you understand everything here. Comments and questions are welcome.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s