我知道以下是不可能的,但是有没有类似的方法来实现必须填写两个属性之一?换句话说,用户必须输入用户名或电子邮件。
public class LogOnModel
{
[Required(OrField=Email)]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required(OrField=UserName)]
[Display(Name = "Email")]
public string Email{ get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}