Chapter 5Forms and HTML Helpers
—by K. Scott Allen
What's In This Chapter?
- Understanding forms
- Making HTML helpers work for you
- Editing and inputting helpers
- Displaying and rendering helpers
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
You can find the wrox.com code downloads for this chapter at http://www.wrox.com/go/proaspnetmvc5 on the Download Code tab. The code for this chapter is contained in the following file: Wrox.ProMvc5.C05.zip.
As their name implies, HTML helpers help you work with HTML. Because it seems like a simple task to type HTML elements into a text editor, you might wonder why you need any help with your HTML. Tag names are the easy part, however. The hard part of working with HTML is making sure the URLs inside of links point to the correct locations, form elements have the proper names and values for model binding, and other elements display the appropriate errors when model binding fails.
Tying all these pieces together requires more than just HTML markup. It also requires some coordination between a view and the runtime. In this chapter, you see how easy it is to establish this coordination. Before you begin working with helpers, however, you first learn about forms. Forms are where most of the hard work happens inside an application, and are where you need to use HTML helpers the most.
USING FORMS
You might wonder why a book targeted at professional web developers covers the HTML form
tag. Isn't it easy to understand?
There are two reasons:
- The form ...
Get Professional ASP.NET MVC 5 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.