Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

How to select values in a CheckBox programmatically



I am creating some pages programmatically and I am adding the value to each property like this:

myPage.Property["PropertyName"].Value = "Some text";

But when I want to do the same to a CheckBox Property linked to a Category I cannot get to add my values, or in this case, to select the right values:

For Example:

I have three checkboxes: US, Canada, Mexico.

How can I select one/more of these values when creating my page programmatically?



Mar 01, 2011 18:27

Are you trying to save a page with categories selected, or are you trying to save a page with a checkbox selector?

The first one I think you can use the newPage.Category.ResolveCategoryNames("US,Canada,Mexico");


Mar 01, 2011 22:50

Hej Anders:


My page type includes serveral fields, most of them text fields and one drop down list and two checkboxes (in the same property).


I can manage to add the data to the text fields and the drop down list but when it comes to check any of the checkboxes I cannot manage to select any of them (programmatically). Therefore my page is created with no problem but no checkbox is selected (if they were supposed to be selected).



Mar 02, 2011 16:38

If you have one propertiy that contains more than one value, I quess this property save the values as text. If you find out what text you should have, you can populate the property by using page.Property["abc"].ParseToSelf("this value is what I want to save")

Mar 02, 2011 20:43

I tried it but it does not work. The CMS is using a custom CheckBoxList Property. This property generates a CheckBoxList from a CagetoryList. I have been checking and to select items programmatically you need to get an item of the checkboxlist and then change the change the value to true. The problem is that I cannot access the checkboxlist of my customProperty, or the only thing I can get is the Value.


Mar 03, 2011 19:35

I solve the problem. The custom property stored the different values in a string with a special format, it was using a separator for each value. So I just had to build the string with the right format and problem solved. Thanks for the help anyways.



Mar 29, 2011 13:39
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.