- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我为 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/
我有一个 poco 类产品 public class Product { public int Id {get;set;} [RequiredEx] public string
我在我的 WPF 应用程序中使用 MVVM 模式,并将具有本地化功能的 DisplayAttribute 应用于我的模型属性: class MyModel { [Display(
我有一个枚举类... public enum LeadStatus : byte { [Display(Name = "Created")] Created = 1, [Display
我有一个像这样的 Helper 方法来获取 PropertyName(试图避免使用魔法字符串) public static string GetPropertyName(Expression> exp
我已经在 Visual Studio 中启动了一个默认的 MVC4 项目, 我模型中的某处是这段代码 public class LoginModel { [Required] [D
因为我们可以使用 System.ComponentModel.DataAnnotations.DisplayAttribute 为属性设置标签,所以我想将它用于类,但不允许在类中使用。 using S
我有一个从 EF4 生成的部分类,我分配了一个 MetadataType 以便在 ASP.NET MVC3 上显示控件的名称,它按预期工作。 我想使用分配给每个属性的相同 DisplayAttribu
我希望显示名称包含一些 html 文本。 例如: [Display(Name = "First Name boldtext)] public string FirstName { get; set;
我有一个基类,它继承了另一个基类的属性,并添加了一个新的属性,如下所示: public class DataSourceWithIntervalBase : DataSourceBase {
我通过以下方式在我的 UI 中创建了一些项目 Buttons.cs [Browsable(true)] [Display(Order = 1, Name = "Object1", GroupName
请帮我在 DisplayAttribute 中添加我尝试过的属性,但将 consturtor 错误设置为 null var fieldName = string.Format(
在 C#6 中,使用 nameof() 关键字,现在可以创建使用本地化的类型安全 Display 属性。(另见 DisplayName attribute from Resources?) 结果会是这
在尝试编译我的 .Dll 时,我设法找出了所有引用资料和错误,除了这两个(我有多个)。 "The type or namespace name 'Display' could not be found
我正在绑定(bind) DataGrid.ItemsSource属性(property)给List目的。我正在通过 支持 Silverlight 的 WCF 服务 获取数据。所以 PersonDeta
我有一个模型类,具有如下属性: [Display(Name = "Phone", Description="Hello World!")] public string Phone1 { get; se
给定具有这些数据注释的模型: public class Example { [Required] [Display(Name = "Activity response")] p
我想知道是否可以将 ASP.NET MVC6 中的 IHtmlLocalizer 直接与 POCO 类一起使用?目前我有几个 View 模型使用 DisplayAttribute 来在 View 和验
给定以下代码: using System.ComponentModel.DataAnnotations; using System.Linq; using Xunit; namespace Compa
class SomeModel { [Display(Name = "Quantity Required")] public int Qty { get; set; } [Di
想知道这是否可能或具有这种效果的东西。 public class MyModel { public string Name { get; set; } [Display(Name =
我是一名优秀的程序员,十分优秀!