考虑我有2个课程,例如:
Class ClsStudent
Public Id As System.Nullable(Of Integer)
<Required(AllowEmptyStrings:=False)> _
<StringLength(45, ErrorMessage:="Name must not exceed 45 characters.")> _
<Display(Name:="Full Name", Description:="Student full name.")> _
Public Name As String = ""
End Class
Class Voila
Public Student As ClsStudent
Public Status As Boolean
End Class
我将voila传递给视图,并希望在视图中访问学生姓名的DisplayNameFor:
@Html.DisplayNameFor(Function(m) m.Student.Name)
但它显示了字段名称:&#34;名称&#34;而不是已分配给它的显示名称属性&#34;全名&#34;。
我的代码出了什么问题?
答案 0 :(得分:0)
好的......在浪费了几个小时之后,我才发现我错过了&#34;属性&#34;到属性名称。它应该是&#34; Public Property Name As String =&#39;&#39;&#34;而不是&#34; Public Name As String =&#39;&#39;&#34;。 Fewss .....:(((