Reputation: 148
I have a razor view with the following:
@Html.EditorForModel()
It displays the properties in the model in the order they appear in the model. Is it possible to order them using some kind of annotation that is already built into the MVC framework (ASP.NET MVC 5.2.6)?
Upvotes: 0
Views: 195
Reputation: 258
Try setting an order on your display attributes within your model for each property, like so:
public class Person
{
[Display(Name = "First Name", Order = 0)]
public string FirstName { get; set; }
[Display(Name = "Last Name", Order = 1)]
public string LastName { get; set; }
}
More information about the DisplayAttribute.Order property can be found here:
Upvotes: 1