It seems like all dynamic properties are null when opening a page in edit mode - isn't that so??
However I tried to use an example from another posting using DynamicPropertyCollection. I don't understand how to get the values from the Dynamic properties.
A property of type PageReference seems to be possible to get from InheritedValue, but for a "Selected" type this value is always empty string. PropertyValue is always null by some reason.
DynamicPropertyCollection dynProperties = DynamicProperty.ListForPage(pd.PageLink);
DynamicProperty dp = dynProperties["Country"];
//works ok
this.Country = (PageReference.Parse(dp.InheritedValue.ToString()));
//PropertyValue always null
this.Country = (PageReference)dp.PropertyValue.Value;
DynamicProperty dp2 = dynProperties["HasCarSubMenu"];
//InheritedValue always ""
this.HasCarSubMenu = (dp2.InheritedValue.ToString().Equals(""));
//PropertyValue always null
this.HasCarSubMenu = (dp2.PropertyValue.IsNull);
How can I reach dynamic values from edit mode, I get crazy ...
/Björn
I assume this is happening when you are first creating a page? When viewing a saved page in edit mode, the page should have all property values available. The best way to access the pages properties (both dynamic and page specific) is to just use the default indexer on the PageData object, e.g. (bool)CurrentPage["HasCarSubMenu"]
The thing with dynamic properties and creating new pages is that the new page will always inherit the dynamic property values from the parent page when first created. So if you need to refer to a dynamic proeprty when a page is first created, you can just use the parent pages collection.
Also, if you want to try and explain what you are trying to achieve, rather than your technical problem, then we may be able to suggestion a different approach.
Cheers,
Jeremy.
No, this does not happen when I create a new page. And there is no problem when viewing the page normally. In edit mode though, I only get null values of the dynamic propertys.
I also asked the partner Inexor and it seems than the dynamic property is only available if the property is set on the same page and not if it is set further up in the epitree.
/Björn
DynamicPropertyCollection dynProperties = DynamicProperty.ListForPage(pd.PageLink); DynamicProperty dp = dynProperties["Country"]; //works ok this.Country = (PageReference.Parse(dp.InheritedValue.ToString())); //PropertyValue always null this.Country = (PageReference)dp.PropertyValue.Value; DynamicProperty dp2 = dynProperties["HasCarSubMenu"]; //InheritedValue always "" this.HasCarSubMenu = (dp2.InheritedValue.ToString().Equals("")); //PropertyValue always null this.HasCarSubMenu = (dp2.PropertyValue.IsNull);
How can I reach dynamic values from edit mode, I get crazy ... /Björn