O'Reilly logo

Applied ASP.NET 4 in Context by Adam Freeman

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

Other View Features

To finish this chapter, I will show you some other features that Razor views support. These don't follow any single theme; they are just useful things to know that can make development easier.

Razor Sections

When I described the @RenderBody tag, I explained that it is used in a layout to insert the contents of the view, except those parts that are in a named section. Listing 25-30 shows the List.cshtml view reworked to include some sections.

Listing 25-30. Defining sections in a Razor view

@model IEnumerable<EventRegistration.Models.Domain.Registration> @{     ViewBag.Title = "List";     Layout = "~/Views/Shared/CustomLayout.cshtml"; } @section Header {     <h4>     @switch (Model.Count()) {         case 0:              ...

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