ASP.NET MVC Html.Display () using ViewData?

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)     // renders as First Name: Joe Smith

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.

+3
source share
1 answer

Html.Display() , viewdata, .

:

Html.Display("something");
+10

Source: https://habr.com/ru/post/1745893/


All Articles