Display and editor templates
This section uses display and editor templates to divide our UIs into model-oriented partial views. These have been available since MVC on the .NET Framework and are not new to ASP.NET Core. Unfortunately, they are often forgotten or overlooked at the expense of brand-new things that come out.
Display templates are Razor views that override the default rendering template of a given type. Editor templates are the same but override the editor’s view of a given type.
Each type can have a display template and an editor template. They are also stored hierarchically so that each type can have globally shared templates and specific ones per area, controller, section, or page. In a complex application, this could be very handy to override an individual template for a particular section of the app.
A display template must be created in a DisplayTemplates
directory, and an editor template must be created in an EditorTemplates
directory. These...