i have a problem internationalizing my code. It pretty much works great everywhere on my site, except in this part of code.
[DataType(DataType.Password)]
[Display(ResourceType = typeof(strings), Name = "BevestigWachtwoord")]
private CultureInfo resourceCulture;
[Compare("Password", ErrorMessage = ResourceManager.GetString("PassMismatch",resourceCulture))]
public string ConfirmPassword { get; set; }
the error(Object reference is required………) is at ResourceManager.GetString(“PassMismatch”,resourceCulture))]
I get the same error if i try ErrorMessage=strings.PassMismatch (where strings is my resourse file)
when i just fill in a string, it does work.
i had the same problem for display, but i fixed that by doing
[Display(ResourceType = typeof(strings), Name = "Email")]
Is there something similar i can try here?
EDIT : My Errors
Error 13 An object reference is required for the non-static field, method, or property ‘MvcApplication2.Models.RegisterModel.resourceCulture’ C:\Users\stuart\documents\visual studio 2010\Projects\MvcApplication2\MvcApplication2\Models\AccountModels.cs 74 86 MvcApplication2
Error 14 An object reference is required for the non-static field, method, or property ‘System.Resources.ResourceManager.GetString(string, System.Globalization.CultureInfo)’ C:\Users\stuart\documents\visual studio 2010\Projects\MvcApplication2\MvcApplication2\Models\AccountModels.cs 74 45 MvcApplication2
Error 11 The expression being assigned to ‘MvcApplication2.Models.RegisterModel.error’ must be constant C:\Users\stuart\documents\visual studio 2010\Projects\MvcApplication2\MvcApplication2\Models\AccountModels.cs 67 30 MvcApplication2
Error 12 The property or indexer ‘MvcApplication2.strings.PassMismatch’ cannot be used in this context because it lacks the get accessor C:\Users\stuart\documents\visual studio 2010\Projects\MvcApplication2\MvcApplication2\Models\AccountModels.cs 67 30 MvcApplication2
for the other comment, i’m trying stuff like
ErrorMessage = resourceCulture ResourceManager.GetString(“PassMismatch”,Thread.CurrentThread.CurrentUICulture))]
but just nothing is working
Replace this line:
With this line:
And make sure you’ve added your PassMismatch string to the resource file that is mapped to your
stringsresource type.