check boxes does not remember state



I have a page that gives content editors the ability to check some checkes boxes. However when they click on publish the checkboxes are cleared. 

The funny thing is that eventhough the checkboxes are cleared, somehow EPiServer remembers the choiches, making it possible for me to retrieve the value of the marked check boxes using the api. 

What can I do to have episerver remember the state of checkboxes. 

Apr 11, 2016 16:42

The check boxes, are they Episerver properties? Can you share some code?

What version are you running on Episerver?

Apr 11, 2016 21:32

Sorry for not supplying any code samples. I hoped it would be needed. 

Its EPiServer CMS 9 and its an EPiServer property.

Here is the code:

The model

        public virtual string SubscriptionPages { get; set; }

The  C# code that creates the checkboxes

    [EditorDescriptorRegistration(TargetType = typeof(string), UIHint = CustomUiHints.SubscriptionPageSelector)]
    public class SubscriptionPageEditorDescriptor : EditorDescriptor
            SelectionFactoryType = typeof(SubscriptionPageSelectionFactory);
            ClientEditingClass = "epi-cms.contentediting.editors.CheckBoxListEditor";
            base.ModifyMetadata(metadata, attributes);

    public class SubscriptionPageSelectionFactory : ISelectionFactory
        public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
            var subscriptionPages = new List<SelectItem>();
            var subscriptions = ...GetSubscriptions
            foreach (var sub in subscriptions)
                subscriptionPages.Add(new SelectItem() { Value = sub.Value, Text = sub.Key });
            return subscriptionPages;

The CustomUIHints files

public const string SubscriptionPageSelector = "SubscriptionPageSelector";

The code is runned inside a scheduledJob. 

The xml structure is as in the picture. (if the picture is not visible then go to this url: )

There is a container page that has children each child has the checkboxes. 

xml tree

When retreving the values of the checkboxes the values are presented in a comma separated list, if the image is not visible, please refer to:


The information given above may be too much, in order to understand why the checkboxes arent preserving their state after publish. 

Note I have not created any controller og view for the model. Since the model will only be used to provide the checkbox list

Edited, Apr 12, 2016 9:36

Try changing



subscriptionPages.Add(new SelectItem() { Value = sub.Value.ToString(), Text = sub.Key });

Apr 12, 2016 10:13

You're the man Daniel. 

That actually worked. 

Maybe you could throw in some few words about why that would do the trick. 

Apr 12, 2016 11:12