Enum Class
public enum DataReleaseChoice
{
Accept,
Decline,
[Display(Name = "Retrieve your application")]
Continue
}
In my view:
<input name="@Html.NameFor(model => model.DataReleaseAuthorization)" type="submit" value="@DataReleaseChoice.Accept" class="btn btn-primary" />
<input name="@Html.NameFor(model => model.DataReleaseAuthorization)" type="submit" value="@DataReleaseChoice.Decline" class="btn btn-primary" />
All I am trying to do is to add a line for the new "Continue" button, but it should show the DisplayAttributes value ("Retrieve your application")
I've looked at the example provided at How to get the Display Name Attribute of an Enum member via MVC razor code? but am struggling to use it in the Razor view. I can display the value in the controller using the following code,
var displayAttribute = PAI.Web.Utilities.EnumHelper<DataReleaseChoice>.GetDisplayValue(DataReleaseChoice.Continue);
but when I use the same in the razor view as follows,
<input name="@Html.NameFor(model => model.DataReleaseAuthorization)" type="submit" value="@PAI.Web.Utilities.EnumHelper<DataReleaseChoice>.GetDisplayValue(DataReleaseChoice.Continue)" class="btn btn-primary" />,
I get the error
Using the generic type 'EnumHelper<T>' requires 1 type arguments
I am using MVC 5.2.3, and have read in other forums that MVC 5 supports DisplayAttribute for Enums out of box.. I am struggling to use it though.