我在我的模型以下類:在MVC 2中使用Html.EditorFor時如何設置字段的外觀順序?
public abstract class Entity : IEntity
{
[ScaffoldColumn(false)]
public int Id { get; set; }
[Required,StringLength(500)]
public string Name { get; set; }
}
和
public class Model : SortableEntity
{
[Required]
public ModelType Type { get; set; }
[ListRequired]
public List<Producer> Producers { get; set; }
public List<PrintArea> PrintAreas { get; set; }
public List<Color> Colors { get; set; }
}
要顯示在視圖中的 「模式」 I類只需調用Html.EditorFor(型號=>模型),但是基類的「名稱」屬性最後呈現,這不是所需的行爲。
是否有可能以某種方式顯示顯示字段的順序?
這裏有一個體面的解決方案http://blog.maartenballiauw.be/post/2010/01/11/Ordering-fields-in-ASPNET-MVC-2-templated-helpers.aspx – duckworth 2010-05-26 20:40:33