Search code examples
c#asp.netasp.net-mvchtml-helper

Html.EditorFor<> equivalent for viewing read-only data?


I am currently using the Html.EditorFor<> method for generating editor fields, however I would like to use something similar for displaying field information in a read-only format such as a details page, i.e. a label with the field name followed by a label with the field value.

Is there currently any equivalent in MVC for generating this? Or am I going to have to create a custom helper?

Thanks in advance.

Edit: I am aware of DisplayFor and LabelFor, is it just a case of manually having to combine these?


Solution

  • I may be missing something but can't you just use Html.LabelFor?

    Edit: May need to be a combination using Html.LabelFor and Html.DisplayFor