Try our conversational search powered by Generative AI!

Make editor set text of c# enum



I have a C# enum:

public enum Priority
Low= 0,
Normal= 1,
High = 2

I would like an editor to be able to associate a text to the enum values like Low => "This is the lowest priority"

Is there a Epi Server property for this?

Oct 14, 2016 10:32
Oct 14, 2016 11:36

But doesn't that solution only allow the editor to choose which value that the property of the enum holds?

I.e the editor can choose if the property should be Low, Normal, High. It doesn't provide the editor with a way to set the text for Low, Normal, High?

Oct 14, 2016 12:25

Not built in but you might use two properties that depends on each others, like they do in this example (but you will have an ordinary enum dropdown and then a simple textbox property and then you build it togheter in your viewmodel)

Oct 14, 2016 12:57

You could have a page type with 2 properties:

1. Dropdown with enum values

2. Text field with friendly name

Then add one page each per option (and language). Then build logic to get friendly name by searching these pages by value...

Add a container page to make it easy to create new options...(restricted to the pagetype above)

A bit old style but works :)

Oct 14, 2016 14:00


Thanks for the help. Just wanted to tell you what I ended up doing:

I used this library: and modified the KeyValueAttribute like

    public class EnumNameValueAttribute : Attribute
        public List<string> ReadOnlyKeys;

        public EnumNameValueAttribute()
            this.ReadOnlyKeys = new List<string>();

        public EnumNameValueAttribute(Type enumType)
            this.ReadOnlyKeys = Enum.GetNames(enumType).ToList();

This enables the editor to set texts on the Enum.

Oct 17, 2016 8:50
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.