0

我希望能够读取ErrorMessage传递给自定义验证属性的字符串,以便可以string.Format()对其进行一些操作。但是我好像找不到?

例如,我有一个自定义属性:

[IsDateBeforeFixedDate(4, 0, 0, ErrorMessage = "*The departure date should be between 4 days and 11 months")]

标为:

  public sealed class IsDateBeforeFixedDateAttribute : ValidationAttribute, IClientValidatable
  {

    public IsDateBeforeFixedDateAttribute(int days, int months, int years) : base(days, months, years)
    {
      //I want to read the ErrorMessage string here! (i.e. "*The departure date should be between 4 days and 11 months")
    }
  }

ErrorMessageString不包含它或ErrorMessage

4

1 回答 1

0

似乎如果我在IsValid方法中访问它,它包含正确的字符串,但它不在构造函数中

于 2013-02-13T16:29:49.033 回答