I'm using dataannotations in an MVC2 app and am a little discouraged when trying to use RESX file resources for error messages.
I've tried the following but keep getting the exception "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type"
[Required(ErrorMessage = Resources.ErrorMessages.Required)]
[Required(ErrorMessageResourceName = Resources.ErrorMessages.Required,
ErrorMessageResourceType = typeof(Resources.ErrorMessages)]
I keep getting that error message unless I replace ErrorMessageResourceName
with "Required" instead of Resources.ErrorMessages.Required
.
Can anyone tell me if I'm doing this right?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…