我的属性名称是“ UglyPropertyName”,我想在使用
时将显示名称更改为“新角色”。@Html.DisplayNameFor(Function(model) model.UglyPropertyName)
使用C#,将[Display(Name =“ Some New Name”)]放在class属性上方将更改显示名称。在VB.net中执行此操作的语法是什么?
Public Class SomeVBClass
Private _UglyPropertyName As String
Public Property UglyPropertyame As String
Get
Return _UglyPropertyName
End Get
Set(value As String)
_UglyPropertyName = value
End Set
End Property
End Class
//摘录自.vbhtml视图
<dt>
@Html.DisplayNameFor(Function(model) model.UglyPropertyName)
</dt>
<dd>
@Html.DisplayFor(Function(model) model.UglyPropertyName)
</dd>
当前,@ Html.DisplayNameFor将使用属性名称“ UglyPropertyName”。我希望它类似于“格式化的属性名称”。
答案 0 :(得分:1)
语法稍有不同
Public Class SomeVBClass
Private _UglyPropertyName As String
<DisplayName("Some New Name")>
Public Property UglyPropertyame As String
Get
Return _UglyPropertyName
End Get
Set(value As String)
_UglyPropertyName = value
End Set
End Property
End Class