我似乎无法找到可确保 2 个或更多文本框相同的注释。
例如:
public class NewPasswordModel
{
public string NewPassword { get; set; }
[MustMatch(Name="NewPassword")] // What is the correct thing to come here.
public string NewPasswordRep { get; set; }
}
最佳答案
您可以使用 native CompareAttribute
public class NewPasswordModel
{
public string NewPassword { get; set; }
[Compare("NewPassword")]
public string NewPasswordRep { get; set; }
}
关于asp.net-mvc - ASP.NET MVC 必须匹配验证属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5330676/