11
MaxLength属性未生成客户端验证属性
我对ASP.NET MVC3客户端验证有一个奇怪的问题。我有以下课程: public class Instrument : BaseObject { public int Id { get; set; } [Required(ErrorMessage = "Name is required.")] [MaxLength(40, ErrorMessage = "Name cannot be longer than 40 characters.")] public string Name { get; set; } } 在我看来: <div class="editor-field"> @Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) </div> 这是我为此字段的文本框获取的生成的HTML: <input …