HTML and CSS Reference
In-Depth Information
Chapter 2
ASP.NET Web Forms
In this chapter I will demonstrate some of the new input types defined by HTML5 and show you how to use these
in an ASP.NET web form. Typically, the TextBox control is used when data needs to be entered on a form. Users
can enter all kinds of data in a TextBox including strings, numbers, dates, and so on. To ensure valid data, the
form would need to supply either server-side or client-side validation logic. The HTML5 specification provides
several new input types that can provide much of this for you.
The following input types are defined (however, not all browsers support all of them yet):
datetime (including datetime-local, date, time, month, and week )
When you build a web form using ASP.NET, the actual HTML that is sent to the browser is generated by .NET.
I'll show you the ASP.NET way of inserting the new input types. Also, using some of the new HTML elements
requires a little extra manipulation and I'll demonstrate how to handle that as well.
Introducing the New Input Types
I'll start out with a fairly simple example to demonstrate how to use the new email control combined with the
placeholder attribute to quickly provide client-side instructions and validation. You'll start by creating a standard
ASP project using the Visual Studio template and then modify the registration page. Then I'll introduce the new
Page Inspector and explain the database support in Visual Studio 2012.
Creating an ASP.NET Project
In this chapter you'll create an ASP.NET project using the standard Web Forms template in Visual Studio 2012.
Start Visual Studio 2012 (or the free version, Visual Studio Express for Web). From the Start Page, click the
New Project link. In the New Project dialog box select the Web category and select the “ASP.NET Web Forms
Application” template, enter Chapter 2 for the project name, and select an appropriate location as shown in
Figure 2-1 .
Search WWH ::

Custom Search