我有一个这样的课程:
Public Class AuthKey
<StringLength(45, ErrorMessage:="Name must not less then 5 characters and not exceed 45 characters.", MinimumLength:=5)>
<Display(Name:="Name", Description:="Authentication name.")> _
Public Property name As String
End Class
我想查看属性显示名称和描述,而不是属性值。我尝试了@ html.display(&#34; Name&#34;)或@html.display(&#34; Description&#34;)和@html.displayfor(function(m)m.name)都没有显示任何内容。如何展示?
答案 0 :(得分:1)
在您的视图页面中添加模型类,然后尝试这样
@Html.DisplayNameFor(model => model.name)