0

I am trying to perform basic compare validation for two fields - password and confirmpassword.

For the error message, I am calling reference to fetch value for errormsg. If I use, I get the following error

An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

[Compare(Constants.NewPassword, ErrorMessage = businessprovider.GetValueByKey(Constants.ErrorMsg))]
Renatas M.
  • 11,694
  • 1
  • 43
  • 62
kaarthick raman
  • 793
  • 2
  • 13
  • 41
  • Attributes are metadata and must be known at compile time and therefore must be constants. You cannot use a method in an attribute –  Jul 15 '16 at 10:28
  • thanks for the response. can you provide a answer of how it can be done? – kaarthick raman Jul 15 '16 at 10:42
  • How what can be done? You cannot use a method to get the error message. You need to provide a constant. –  Jul 15 '16 at 10:47

0 Answers0