I have a view model with a property on it that looks like this:
[Display(Name = "Some Property", Description = "This is description", Prompt = "This is prompt")]
[Required(ErrorMessage = RequiredFieldMessage)]
public string SomeProperty { get; set; }
But this does not seem to render anything extra in the view. Do you need to do some additional work?
<div class="editor-label">
@Html.LabelFor(model => model.SomeProperty )
</div>
<div class="editor-field">
@Html.TextAreaFor(model => model.SomeProperty , 5, 80, null)
@Html.ValidationMessageFor(model => model.SomeProperty )
</div>
Not all of the built in EditorTemplates take advantage of all of the DataAnnotations, but they are there for when you write your own EditorTemplates you can leverage them.
Ordering doesn't really apply unless you are doing DisplayForModel
or EditorForModel
where its showing multiple editors for all the properties on the model, it can then order the Editor's appropriately.
If you wanted to take advantage of the Description
and Prompt
metadata you could write your own String
EditorTemplate:
@model string
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new {
@title = ViewData.ModelMetadata.Description,
@placeholder = ViewData.ModelMetadata.Watermark})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With