Tag: componentmodel

ASP.NET MVC3:ValidationType ModelClientValidationRule

我刚刚创建了一个示例MVC3应用程序来学习validation。 它正在使用DataAnnotations。 我创建了一个名为CustomStartLetterMatch的自定义ValidationAttribute 。 它正在实现“System.Web.Mvc.IClientValidatable”。 我有相应的客户端代码用不引人注目的jQuery编写。 这是按预期工作的。 关于自定义validation器:它比较第一个名称输入和姓氏输入。 如果它们的第一个字符不相同,则抛出错误。 正如我所说,该应用程序运行正常。 但是当我查看规则时rule.ValidationType = “greaterdate”; 我很困惑。 我想把它改成像“anotherDefaultType”这样的东西。 当我更改它时,它失败并出现jQuery错误。 这是什么原因? 有哪些可用的ValidationTypes? 在此场景中更改ValidationType的建议方法是什么? 码: using System; using System.ComponentModel.DataAnnotations; using System.Collections.Generic; namespace MyValidationTEST { public class Person { [Required(ErrorMessage = “First name required”)] public string FirstName { get; set; } [CustomStartLetterMatch(“FirstName”)] [StringLength(5,ErrorMessage = “Must be under 5 characters”)] public string […]