Question: #DisplayFor is not working in #MVC Asp.Net Core View and the #Component, what am I doing wrong?
I have my #Modal #Class defined as below:
public sealed partial class CompositionQuestionaire
{
[Key]
public int Id { get; set; }
[Display(Name = "Have there been any changes in household composition in the last twelve months?")]
public bool AnyChangesInLast12Months { get; set; }
}
And I am trying to render the Display Name as shown below:
<div class="col-6">
@Html.DisplayFor(a => a.CompositionQuestionaire.AnyChangesInLast12Months)
</div>
The above-shown #DisplayFor @HTML Tag Helper in MVC is not working, what am I doing wrong?
Login to See the Rest of the Answer
Answer: Use the @Html.DisplayNameFor instead of DisplayFor, I hope this helps you.
Helpful Resources:
1. https://buildstarted.com/2010/09/29/htmlhelper-guide-for-mvc-3-part-2/
2. https://jakeydocs.readthedocs.io/en/latest/data/index.html
Yes
Lidia said:
How to contact you?