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:
I have three checkboxes: US, Canada, Mexico.
How can I select one/more of these values when creating my page programmatically?
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");
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).
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")
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.
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.