Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 从自定义验证属性中访问ErrorMessage_Asp.net Mvc 3_Unobtrusive Validation_Validationattribute - Fatal编程技术网

Asp.net mvc 3 从自定义验证属性中访问ErrorMessage

Asp.net mvc 3 从自定义验证属性中访问ErrorMessage,asp.net-mvc-3,unobtrusive-validation,validationattribute,Asp.net Mvc 3,Unobtrusive Validation,Validationattribute,我希望能够读取传递到自定义验证属性中的ErrorMessage字符串,以便对其执行一些string.Format()ing操作。但我好像找不到它 例如,我有一个自定义属性: [IsDateBeforeFixedDate(4, 0, 0, ErrorMessage = "*The departure date should be between 4 days and 11 months")] 贴花为: public sealed class IsDateBeforeFixedDateAttr

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

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

[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

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