2010-04-22 74 views

回答

3

你可以試試這個方法:

[System.ComponentModel.DataAnnotations.CustomValidation(typeof(Test), "Verify", ErrorMessage = "No match!")] 
public class Test 
{ 
    [Required] 
    public string Password { get; set; } 

    [Required] 
    public string ConfirmPassword { get; set; } 

    public static ValidationResult Verify(Test t) 
    { 
     if (t.Password == t.ConfirmPassword) 
      return ValidationResult.Success; 
     else 
      return new ValidationResult(""); 
    } 
} 
相關問題