MVC 3 Razor EditorTemplate / DisplayTemplate master page

Has anyone understood how to use the master pages for the editor and DisplayTemplates with Razor, similar to what is described here by Brad Wilson?

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-5-master-page-templates.html

thanks

+4
source share
1 answer

It didn't turn out to be as complicated as I originally thought.

A little caveat: this is not fully tested and is a simple example to make it work.

This is what I did:

~ / Views / Shared / _TemplateMaster.cshtml

<div class="editor-label"> <label for="@ViewData.ModelMetadata.PropertyName">@ViewData.ModelMetadata.GetDisplayName()</label> </div> <div class="editor-field"> @RenderSection("DataContent") </div> <div> @Html.ValidationMessage("") </div> 

~ / Views / Shared / EditorTemplates / String.cshtml

 @{ Layout = "~/Views/Shared/_TemplateMaster.cshtml"; } @section DataContent { @Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { @class = "" }) } 
+7
source

Source: https://habr.com/ru/post/1343456/


All Articles