I have below ViewModel:
public class RegisterViewModel
{
[Display(Name = "First Name")]
public string FirstName { get; set; }
}
In my view, I'm using DevExtreme components and syntaxes.
when creating the page using following code:
<div class="form-group">
@Html.DevExtreme().TextBoxFor(m => m.FirstName).Placeholder("First Name")
</div>
I don't want to hard-code "First Name"
for Placeholder
and like to use value of Display
attribute instead.
I reviewed couple of answers in SO but could not figure out how to do that.
some of the posts are talking about ModelMetadata
but I can't figure out how to do that.
Any help will be appreciated.
I post the answer here to probably help others. Thanks to @Stephen Muecke
<div class="form-group">
@Html.DevExtreme().TextBoxFor(m => m.FirstName)
.Placeholder(Html.DisplayNameFor(m => m.FirstName).ToString())
</div>