Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 流畅的验证不适用于剑道下拉列表_Asp.net Mvc_Asp.net Mvc 4_Kendo Ui_Kendo Grid_Kendo Asp.net Mvc - Fatal编程技术网

Asp.net mvc 流畅的验证不适用于剑道下拉列表

Asp.net mvc 流畅的验证不适用于剑道下拉列表,asp.net-mvc,asp.net-mvc-4,kendo-ui,kendo-grid,kendo-asp.net-mvc,Asp.net Mvc,Asp.net Mvc 4,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,嗨,我正在使用剑道下拉控件,我在其中使用了流畅的验证,但当我运行它时。“剑道”下拉列表中的验证无效 这是剑道下拉列表,按父类ID绑定 @(Html.Kendo().DropDownListFor(model=>model.Parent_Category_ID) .Name("Parent_Category_ID") .OptionLabel("-----------Select Parent Category-----------")

嗨,我正在使用剑道下拉控件,我在其中使用了流畅的验证,但当我运行它时。“剑道”下拉列表中的验证无效

这是剑道下拉列表,按父类ID绑定

@(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)
这就是我的fluent 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; }
    }

在您的CategorValidator中,您的父类别ID有一个重复的规则。根据验证消息,它似乎不是有意的。

它的键入错误。。。。但是如果我对它进行验证。。。验证不起作用。。