When I use the Html.DisplayFor () property using the model property, it looks great with both a label for the property name and a text box or label with the property value:
Html.DisplayFor(model => model.FirstName)
But if I try to use the same for something that is in ViewData, it has no way to specify the text to be used in the label in rendered html:
Html.Display(ViewData["something"].ToString()) // renders as (no label) something
Other Html.Display () options do not look useful:
Html.Display(ViewData["something"].ToString(), "TemplateName", "HtmlElementId", {additionalData})
It seems that the only place where I could pass the label is with the extra data parameter, but I did not find examples or documents on how to do this.
source
share