I pass in a string through a constructor that i want to use as my error message in my model class like this:
public class ContactForm
{
public string NameError { get; set; }
public ContactForm(string nameError)
{
NameError = nameError;
}
[Required(ErrorMessage = NameError)]
public string Name { get; set; }
//More properties
}
Here i get the exception:
An object reference is required for the non-static field, method, or property 'UmbracoSport.Models.ContactForm.NameError.get' D:\Umbraco\Websites\UmbracoSport\UmbracoSport\Models\Custom\ContactForm.cs 19 34 UmbracoSport
If i make NameError static i get this error:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type D:\Umbraco\Websites\UmbracoSport\UmbracoSport\Models\Custom\ContactForm.cs 19 34 UmbracoSport
Is this in any way possible ?