What's the recommended way to display localized enum properties in MVC2?
If I have a model like this:
public class MyModel {
public MyEnum MyEnumValue { get; set; }
}
and a line in the view like this:
<%: Html.DisplayFor(model => model.MyEnumValue) %>
I was hoping to just annotate the enum values with DisplayAttribute
like this:
public enum MyEnum
{
[Display(Name="EnumValue1_Name", ResourceType=typeof(Resources.MyEnumResources))]
EnumValue1,
[Display(Name="EnumValue2_Name", ResourceType=typeof(Resources.MyEnumResources))]
EnumValue2,
[Display(Name="EnumValue3_Name", ResourceType=typeof(Resources.MyEnumResources))]
EnumValue3
}
That's not supported. It seems there's something else needed. What's the nicest way to implement it?