gpt4 book ai didi

asp.net-mvc - DataAnnotations.DisplayAttribute.Order 属性是否不适用于 ASP.NET MVC 2?

转载 作者:行者123 更新时间:2023-12-04 13:04:59 24 4
gpt4 key购买 nike

我为 Order property 设置了值的 Display attribute在我的模型元数据中。

[MetadataType(typeof(OccasionMetadata))]
public partial class Occasion
{
private class OccasionMetadata
{
[ScaffoldColumn(false)]
public object Id { get; set; }

[Required]
[Display(Name = "Title", 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; }
}
}

我使用 DisplayForModel 在强类型 View 中展示我的模型和 EditorForModel方法。

<%= Html.DisplayForModel() %>

<%= Html.EditorForModel() %>

但是,ASP.NET MVC 2 显示的字段是乱序的!我可能有什么问题?

最佳答案

.NET 4 DataAnnotations comes with a new Display attribute that has several properties including specifying the value that is used for display in the UI and a ResourceType. Unfortunately, this attribute is new and is not supported in MVC 2 RTM.

The good news is it will be supported and is currently available in the MVC Futures release.

The steps to get this working are shown below...

来自 Localization in ASP.NET MVC 2 using ModelMetadata作者:拉吉凯马尔

关于asp.net-mvc - DataAnnotations.DisplayAttribute.Order 属性是否不适用于 ASP.NET MVC 2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2837952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com