我希望能够读取传递到自定义验证属性中的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
发布于 2013-02-14 00:29:49
如果我在IsValid方法中访问它,它似乎包含正确的字符串,但在构造器中却没有
https://stackoverflow.com/questions/14857936
复制相似问题