Monday, April 29, 2013

TextMode Property in ASP.NET 4.5

With ASP.NET 4.5 we have been provided full HTML5 support. Taking the example of textbox, we have text mode property which can be set to different values such as :
a) SingleLine
b) Multiline
c) Password
d) Number
e) Range
f) Date
g) Color

Now, all these textmode property support varies from browser to browser. Some textmode property values are supported by IE or chrome.

So, let's start and see important textmode property values

1) Set the textmode property = "Password"

It would give you textbox, where you have to enter the Password but you would see that when you enter the characters in the textbox, they would be shown as "DOTS". Please see below image

Also, if enter the character as 'abc' rather than entering the complete email address, then it provides me alert to 'Enter the email address'. Below is the image

2) Setting the textmode property="URL"
Below is the code
<asp:TextBox ID="txtUrl" runat="server" TextMode="Url" ></asp:TextBox>

However, i don't enter the URL in correct format, it would display the error as below

3) Setting the textmode property="Range"
<asp:TextBox ID="txtRange" runat="server" TextMode="Range" ></asp:TextBox>

4) Setting the textmode peoperty="Number"
 <asp:TextBox ID="txtNumber" runat="server" TextMode="Number"  ></asp:TextBox>

This means that in this textbox we can only enter numbers. However, if one enters characters it would give alert message like below

5)  Setting the textmode peoperty="Date"
 <asp:TextBox ID="txtDate" runat="server" TextMode="Date"  ></asp:TextBox>
This would give option to enter the date from calendar.

6 )  Setting the textmode peoperty="Color"
<asp:TextBox ID="txtColor" runat="server" TextMode="Color"  ></asp:TextBox>

This would give option to select color like below

Hope this article of mine gives you clear idea of textmode property of textbox.

1 comment:

  1. Hi, how can I control the textbox textmode = date where the past dates are disable for selection?