使用@Html.DisplayFor 而不是@item 有什么优势?
What are the advantages of using @Html.DisplayFor rather than @item?
使用 lets say 有什么好处
@Html.DisplayFor(modelItem => item.Example)
而不是
@item.Example
在 table 设置中 @foreach(模型中的变量项)?
他们看起来很像。
可能重复:When should I use Html.Displayfor in MVC
总结:
@* Can be used with a DisplayTemplate for extended displaying for the Type. *@
@Html.DisplayFor(modelItem => item.Example)
@* Only displays a HTML encoded (to better protect against XSS attack) string representation of the value. *@
@item.Example
使用 lets say 有什么好处
@Html.DisplayFor(modelItem => item.Example)
而不是
@item.Example
在 table 设置中 @foreach(模型中的变量项)?
他们看起来很像。
可能重复:When should I use Html.Displayfor in MVC
总结:
@* Can be used with a DisplayTemplate for extended displaying for the Type. *@
@Html.DisplayFor(modelItem => item.Example)
@* Only displays a HTML encoded (to better protect against XSS attack) string representation of the value. *@
@item.Example