CHAPTER 22

image

Templated Helper Methods

The HTML helpers that I looked at in the previous chapter, such as Html.CheckBoxFor and Html.TextBoxFor, generate a specific type of element, which means that I have to decide in advance what kinds of elements should be used to represent model properties and to manually update the views if the type of a property changes.

In this chapter, I demonstrate the templated helper methods, with which I specify the property I want displayed and let the MVC Framework figure out what HTML elements are required. This is a more flexible approach to displaying data to the user, although it requires some initial care and attention ...

Get Pro ASP.NET MVC 5, Fifth Edition 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.