Html.EditorFor <>等同于查看只读数据?

Str*_*ial 17 c# asp.net asp.net-mvc html-helper

我目前正在使用Html.EditorFor <>方法生成编辑器字段,但我想使用类似的东西以只读格式显示字段信息,例如详细信息页面,即带有字段名称后跟一个标签的标签带有字段值的标签.

目前在MVC中是否有任何等效的产生?或者我将不得不创建一个自定义助手?

提前致谢.

编辑:我知道DisplayFor和LabelFor,它只是手动必须组合这些?

zih*_*tki 36

使用

<%= Html.DisplayFor(model => model.Property) %>
Run Code Online (Sandbox Code Playgroud)

或者,如果您想查看只读(禁用)文本框

<%= Html.TextBoxFor(model => model.Property, new { disabled="disabled", @readonly = "readonly" })%>
Run Code Online (Sandbox Code Playgroud)


Man*_*rin 5

我可能遗漏了一些东西,但你不能使用Html.LabelFor吗?

编辑:可能需要结合使用Html.LabelForHtml.DisplayFor