O'Reilly logo

Professional ASP.NET MVC 3 by K. Scott Allen, Brad Wilson, Phil Haack, Jon Galloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Forms

You might wonder why a book targeted at professional web developers is going to spend time covering the HTML form tag. Isn't it easy to understand?

There are two reasons.

  • The form tag is powerful! Without the form tag, the Internet would be a read-only repository of boring documentation. You wouldn't be able to search the Web, and you wouldn't be able to buy anything (even this book) over the Internet. If an evil genius stole all the form tags from every website tonight, civilization would crumble by lunchtime tomorrow.
  • Many developers coming to the MVC framework have been using ASP.NET WebForms. WebForms don't expose the full power of the form tag (you could say WebForms manages and exploits the form tag for its own purposes). It's easy to excuse the WebForms developer who forgets what the form tag is capable of—such as the ability to create an HTTP GET request.

The Action and the Method

A form is a container for input elements: buttons, checkboxes, text inputs, and more. It's the input elements in a form that enable a user to enter information into a page and submit information to a server. But what server? And how does the information get to the server? The answers to these questions are in the two most important attributes of a form tag: the action and the method attributes.

The action attribute tells a web browser where to send the information, so naturally the action contains a URL. The URL can be relative, or in cases where you want to send information to a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required