displayattribute

How to get the Display Name Attribute of an Enum member via MVC razor code?

人走茶凉 提交于 2019-11-25 23:36:57
问题 I\'ve got a property in my model called \"Promotion\" that its type is a flag enum called \"UserPromotion\". Members of my enum have display attributes set as follows: [Flags] public enum UserPromotion { None = 0x0, [Display(Name = \"Send Job Offers By Mail\")] SendJobOffersByMail = 0x1, [Display(Name = \"Send Job Offers By Sms\")] SendJobOffersBySms = 0x2, [Display(Name = \"Send Other Stuff By Sms\")] SendPromotionalBySms = 0x4, [Display(Name = \"Send Other Stuff By Mail\")]