O'Reilly logo

ASP.NET MVC 2 Cookbook by Richard Kimber, Andrew Siemer

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 HTML helpers to create forms

In this recipe, we will take a look at how to create a form manually using HTML helpers. This will include creating the form, checkboxes, textboxes, and so on. We will work with a strongly typed view based on an Article object that we will quickly put together.

How to do it...

  1. The first step of this recipe is to create a new ASP.NET MVC 2 empty web application.
  2. Once created, add a new class to the Models folder called Article. Drop in the preceding code snippet.
  3. Because we've elected to use an empty project, we'll need to create our home controller from scratch. Right-click on the Controllers folder and add a controller called HomeController.
  4. We will also need a master page; right-click on the Shared folder (in

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