1
public class Test
{
[RelativeDateTimeValidator(-10, DateTimeUnit.Year, 10, DateTimeUnit.Year, ErrorMessage = "Error")]
public DateTime ADate { get; set; }
public void ValidateMyProperty()
{
ADate = new DateTime(1900, 01, 01);
ValidationResults vrs = Validation.Validate<Test>(this);
foreach (var vr in vrs)
{
Print(vr.Message);
}
}
}
The value must fall within the range "-10"(Year) - "10(Year) relative to now
然而,我怎樣diplay /訪問,我已指定的錯誤消息(的ErrorMessage = 「錯誤」)?
在此先感謝。
好東西,謝謝。 – Craig 2012-02-16 19:36:46