Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
The check boxes, are they Episerver properties? Can you share some code?
What version are you running on Episerver?
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
[UIHint(CustomUiHints.SubscriptionPageSelector)] public virtual string SubscriptionPages { get; set; }
The C# code that creates the checkboxes
[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = CustomUiHints.SubscriptionPageSelector)] public class SubscriptionPageEditorDescriptor : EditorDescriptor { public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes) { 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: http://tinypic.com/r/5aj09k/9 )
There is a container page that has children each child has the checkboxes.
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: http://postimg.org/image/phklg4dcn/
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
Try changing
subscriptionPages.Add(new SelectItem() { Value = sub.Value, Text = sub.Key });
to
subscriptionPages.Add(new SelectItem() { Value = sub.Value.ToString(), Text = sub.Key });
You're the man Daniel.
That actually worked.
Maybe you could throw in some few words about why that would do the trick.
Hi
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.