Try our conversational search powered by Generative AI!

Dynamic selected/not selected

Vote:
 
Hi, I'm having problems with my selected/not selected dynamic properties. I use several of these properties to control which parts of the web site that should be visible or not. The problem is that I'm unable to set false values on pages that are below the start page. The value is true no matter if I choose to check the "set specified value for all child pages" on the start page or not. It seems like a non-checked box on any of the child pages is considered as a non-value rather than a false, and the value is inherited from the parent. What I would like to do is to let these boxes be true for pages in the top of the hierarchy, and let them be false on pages lower below. Isn't this supposed to be possible? Best regards, Christoffer
#12849
Nov 27, 2006 17:55
Vote:
 
This is by design. A "selected/not selected" can only be true or null. You need to write your own property, possibly inheriting from PropertyNumber, which could store both true and false. I know that this is quite common, especially for dynamic properties. If the value is null, you can present the value in a drop down as "inherits value from parent" along with "true" and "false". /Steve
#14990
Nov 28, 2006 6:57
Vote:
 
Thanks for the answer. I managed to create a custom property based on the example in the EPiServer book on page 203 - A drop down list that inherits from PorpertyNumber. I also added an empty ListItem so that the user can clear the value of the property. Everything seems to be working fine now except for one thing - when I change a value and click "save", the value is updated but the drop down list stills shows the old value. When reload the dynamic properies page, the correct new value is presented. Has anyone encountered this problem before? Any ides of what the problem could be? This is the code inside my class: private DropDownList ChoiceDropDownList; public override void CreateChildControls(string renderType, Control container) { switch(renderType.ToLower()){ case "edit": ChoiceDropDownList = new DropDownList(); ChoiceDropDownList.ID = Name; CopyWebAttributes(container, ChoiceDropDownList); ChoiceDropDownList.Items.Add(new ListItem()); ChoiceDropDownList.Items.Add(new ListItem("Yes", "1")); ChoiceDropDownList.Items.Add(new ListItem("No", "0")); ChoiceDropDownList.SelectedIndex = 0; if(base.Value!=null){ switch((int)(base.Value)){ case 1: ChoiceDropDownList.SelectedIndex = 1; break; case 0: ChoiceDropDownList.SelectedIndex = 2; break; } } CopyWebAttributes(container, ChoiceDropDownList); container.Controls.Add(ChoiceDropDownList); container.Controls.Add(CreateParseValidator(ChoiceDropDownList)); break; default: base.CreateChildControls(renderType, container); break; } }
#14991
Nov 28, 2006 13:46
* 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.