c# - Apply localization through resource files to DisplayAttribute -
i've started default mvc4 project in visual studio,
somewhere in model 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 change because want try localization (which works within class, not here) (strings=resx file 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 must constant expression, when make that, 'property index lacks accessor'
what missing here?? why cant assign string value darn thing? in java easier. hope can me out.
you should use resources. in attributes can set immutable values.
try this.
[display(name = "remember me?", resourcetype = typeof(yourresourcestype))] public bool rememberme { get; set; } and asp.net mvc 3 localization displayattribute , custom resource provider
Comments
Post a Comment