I have an enum in my project like this:
public enum Gender
{
[Display(Name="Gender.Male")]
Male,
[Display(Name="Gender.Female")]
Female
}
When I use the code below, it retrieves the name of Gender value from .resx files automatically and displays the translated value in razor view.
@Html.DisplayFor(x => x.Gender) //result: Männlich
but, how to get localized names of Gender values in the backend? or how to use DisplayFor or something like that in controller class?
//Desired
string gender = DisplayFor(x => x.Gender); //gender = "Männlich"
Should I code a new method instead of using DisplayFor?