流畅的验证不适用于剑道下拉列表

时间:2015-01-23 06:47:58

标签: asp.net-mvc asp.net-mvc-4 kendo-ui kendo-grid kendo-asp.net-mvc

嗨我正在使用Kendo下拉控件,我使用了Fluent验证,但是当我运行它时。验证不适用于剑道下拉。

这是通过Parent_Category_ID

绑定的Kendo下拉列表
@(Html.Kendo().DropDownListFor(model=>model.Parent_Category_ID)
          .Name("Parent_Category_ID")
          .OptionLabel("-----------Select Parent Category-----------")
          .DataTextField("CategoryName")
          .DataValueField("ID")
          .HtmlAttributes(new { style = "width:300px", })
          .Filter(FilterType.StartsWith)
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action("GetCategory", "Category");
              })
              .ServerFiltering(true);
          })
    )
    @Html.ValidationMessageFor(model => model.Parent_Category_ID)

这是我流利的Control ModelValidator

public CategoryValidator()
        {
            RuleFor(x => x.Category_Name).NotNull().WithMessage("Category Must Not be Empty !").Length(6).WithMessage("Category Name should be 6 character Long !");
            RuleFor(x => x.Parent_Category_ID).NotNull().WithMessage("Parent Category must Not be empty !");
            RuleFor(x => x.Category_Desc).NotNull().WithMessage("Please Write Some Description !");
        }

和此类别模型

 public class CategoryModel
    {
        [Key]
        public int Category_ID { get; set; }
        public int Parent_Category_ID { get; set; }
        public string Category_Name { get; set; }
        public string Category_Desc { get; set; }
        public bool IsGenderApplicable { get; set; }
        public bool IsAgeApplicable { get; set; }
        public bool IsActive { get; set; }
    }

1 个答案:

答案 0 :(得分:0)

在您的CategorValidator中,您有一个Parent_Category_ID的重复规则。根据验证消息,看起来不是故意的。