HTML and CSS Reference
In-Depth Information
Using the
color
input type is just a matter of setting the
type
attribute of an
<input>
element to
color
,
as shown here:
<input id="color1" type="color" />
Once the user selects a color, the value of the
<input>
field returns the corresponding hexadecimal
color code. For example, selecting a white color returns
#ffffff
. By default, the color picker defaults to
black
(#000000
).
Search
The
search
input type is intended to be used for search boxes. Currently, browsers don't provide anything
special for the
search
input type except a few display changes. For example, Chrome displays a cross (X) as
you start typing in the search box (see Figure 5-9). Clicking the X clears the search box.
Figure 5-9.
Search input type in Chrome
Now that you know what new input types are available and how to use them in a web page, it's time to
see how you can use these input types in Web Forms and MVC views.
Using the New Input Types in Web Forms
In ASP.NET 4.5, you can set the
TextMode
property of a
TextBox
server control to the required input type.
Prior to ASP.NET 4.5, the
TextMode
property took only two values:
SingleLine
and
MultiLine
. In ASP.NET
4.5, however, all the new input types are supported, as is evident in Figure 5-10.