Reputation: 15
My property name is "UglyPropertyName" and I want to change the Display Name to "New Role" in my view when using
@Html.DisplayNameFor(Function(model) model.UglyPropertyName)
With C#, putting [Display(Name="Some New Name")] above the class property will change the display name. What is the syntax to do this in 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
//Snippet From .vbhtml view
<dt>
@Html.DisplayNameFor(Function(model) model.UglyPropertyName)
</dt>
<dd>
@Html.DisplayFor(Function(model) model.UglyPropertyName)
</dd>
Currently the @Html.DisplayNameFor will use the property name "UglyPropertyName". I want it to be something like "Formatted Property Name".
Upvotes: 1
Views: 356
Reputation: 15772
It's just slightly different syntax
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
Upvotes: 1