Honestly, I have no idea what to call it and how to start searching for it.
I have a display page with a standard layout.
<div> <label for="field">Field Name:</label> @Model.Field </div>
When trying to make it more convenient to change, I want to create a template instead of entering each field with the above code.
I created a partial view with the following:
@model System.Object <div> @Html.LabelFor(m => m) @Html.DisplayFor(m => m) </div>
In my opinion, I added the following:
@Html.Partial("_BillField", Model.Field)
Then the model has a description with the following:
public ModelName { [Display(Name="Field Description")] public decimal Field { get; set; } }
This works when on the main view, but the label is missing when using the template. What am I missing?
Update: Per @K. Bob, I am making changes to the partial view:
<div> @Html.LabelFor(m => m) @Html.DisplayFor(m => m) </div>
Update 2: For clarity of what I want.
In the end, I want to be able to:
@Html.Partial("_BillField", Model.Field1) @Html.Partial("_BillField", Model.Field2) @Html.Partial("_BillField", Model.Field3)
And have the equivalent:
<div> <label for="field1">Field 1 Name:</label> @Model.Field1 </div> <div> <label for="field2">Field 2 Name:</label> @Model.Field2 </div> <div> <label for="field3">Field 3 Name:</label> @Model.Field3 </div>
Sorry for not understanding this.