How do I create a MVC Razor template for DisplayFor()
OK, I found it and it’s actually very simple. In my Views\Shared\DisplayTemplates folder I have Reading.cshtml containing the following: @model System.Int32 <span id=”@ViewData.ModelMetadata.PropertyName”>@Model</span> This renders the correct tag using the name of the property as the id attribute and the value of the property as the contents: <span id=”Reading”>1234</span> In the view file this can … Read more