Creating an Inline HTML Helper
Razor supports the inline HTML helpers, which allows us to avoid repetition in our views by placing markup and tags into a reusable block. Listing 25-23 shows a simple inline helper.
Note Inline helpers are different from the HTML helper methods that we saw in Chapter 23, such as @Html.Editor
. I'll show you the HTML helper methods in more detail in Chapter 26.
Listing 25-23. A simple Razor inline HTML helper
@model IEnumerable<EventRegistration.Models.Domain.Registration>
@{
ViewBag.Title = "List";
}
@helper CreateOrdinal(int index) {
switch (index.ToString().Last()) {
case '1': ...
Get Applied ASP.NET 4 in Context 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.