I've started a default MVC4 project in Visual Studio,
Somewhere in my model is this piece of code
public class LoginModel
{
[Required]
[Display(Name ="Name")]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
I want to change it to something like this because i want to try localization (which works within another class, but not here) (strings=resx file for localization)
public class LoginModel
{
[Required]
[Display(Name =strings.UserName)]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = strings.Password)]
public string Password { get; set; }
[Display(Name = strings.RememberMe)]
public bool RememberMe { get; set; }
}
The error is it must be a constant expression, but when I make it like that, then I get something like 'property index lacks accessor'
What am I missing here?? Why cant I just assign a string value to the darn thing? In Java this is all so much easier. Hope you can help me out.