Why can’t I do like this?
[Required(ErrorMessage = "*")]
[RegularExpression("^[a-zA-Z0-9_]*$", ErrorMessage = Resources.RegistrationModel.UsernameError)]
public string Username { get; set; }
What is the error message telling me?
An attribute argument must be a
constant expression , typeof
expression or array creation
expression of an attribute parameter
type.
When you are using the
ErrorMessageproperty only constant strings or string literal can be assigned to it.Use the
ErrorMessageResourceTypeandErrorMessageResourceNameinstead to specity your resources.Note that the resources must be public (can be set in the resource editor).