Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public static class EnumExtension
  2. {
  3. public static string GetDisplayName(this Enum enumValue)
  4. {
  5. return enumValue.GetType()
  6. .GetMember(enumValue.ToString())
  7. .First()
  8. .GetCustomAttribute<DisplayAttribute>()
  9. .GetName();
  10. }
  11. }
  12.  
  13. // Generate members in cshtml
  14. // <select asp-for="Property" asp-items="Html.GetEnumSelectList<BookType>()" ></select>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement