Chapter 3. Working with Forms

In This Chapter

Forming HTML forms

Creating text boxes

Punching radio buttons

Buttoning down lists

Processing form submissions with ASP.NET

Keeping your tabs in order

A form is an HTML element that contains input controls through which a user can enter data that he or she wants to submit to the Web server. Using forms is the essence of ASP.NET Web programming, as all ASP.NET Web pages ultimately are rendered as HTML forms that are sent to the browser.

In this chapter, you can discover the ins and outs of forms. Even if you never code an HTML form on your own, understanding what HTML forms can and can’t do may give you a better understanding of how ASP.NET server controls work.

Understanding Forms

In HTML, the <form> and </form> tags mark a specialized area of the document in which users can select items and type in data. The form collects user input and submits it somewhere, usually to a Web server for further processing.

The HTML form can hold several types of input controls, including text fields, drop-down lists, buttons, check boxes, and radio buttons. We look at each of these controls in detail in this chapter. For starters, here’s the HTML markup for a typical form that lets the user make some choices:

<form action="http://www.kencox.ca/usubmitted.aspx" method="post"> Please tell us why you get up in the middle of the night:<br /><br /> <input id="Radio1" name="Radio1" type="radio" value="water" /> To get a glass of water<br /> <input id="Radio2" name="Radio2" ...

Get ASP.NET 2.0 All-In-One Desk Reference For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.