November Happy Hour will be moved to Thursday December 5th.

How to select values in a CheckBox programmatically

Vote:
 

Hi:

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?

 

Thanks

#49040
Mar 01, 2011 18:27
Vote:
 

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");

 

#49043
Mar 01, 2011 22:50
Vote:
 

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).

Thanks.

 

#49056
Mar 02, 2011 16:38
Vote:
 

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")

#49061
Mar 02, 2011 20:43
Vote:
 

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.

 

#49103
Mar 03, 2011 19:35
Vote:
 

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.

 

 

#49711
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.