Reputation: 331
I have a class like this:
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
I'd like to view the property display name and description, not the property value. I try to both @html.display("Name") or @html.display("Description") and @html.displayfor(function (m) m.name) all show nothing. How to show it?
Upvotes: 0
Views: 2285
Reputation: 1190
add model class in your view page after that try like this
@Html.DisplayNameFor(model => model.name)
how-to-access-the-model-from-the-view
Upvotes: 1