Does the DataAnnotations.DisplayAttribute.Order property not work with ASP.NET MVC 2?
Posted
by Zack Peterson
on Stack Overflow
See other posts from Stack Overflow
or by Zack Peterson
Published on 2010-05-14T22:10:15Z
Indexed on
2010/05/14
22:14 UTC
Read the original article
Hit count: 518
I set values for the Order property of the Display attribute in my model metadata.
[MetadataType(typeof(OccasionMetadata))]
public partial class Occasion
{
private class OccasionMetadata
{
[ScaffoldColumn(false)]
public object Id { get; set; }
[Required]
[DisplayName("Title")]
[Display(Order = 0)]
public object Designation { get; set; }
[Required]
[DataType(DataType.MultilineText)]
[Display(Order = 3)]
public object Summary { get; set; }
[Required]
[DataType(DataType.DateTime)]
[Display(Order = 1)]
public object Start { get; set; }
[Required]
[DataType(DataType.DateTime)]
[Display(Order = 2)]
public object Finish { get; set; }
}
}
I present my models in strongly-typed views using the DisplayForModel and EditorForModel methods.
<%= Html.DisplayForModel() %>
and
<%= Html.EditorForModel() %>
But, ASP.NET MVC 2 displays the fields out of order! What might I have wrong?
© Stack Overflow or respective owner