Question

I tried to set it as a normal page-property, but no luck.

Guess I could use the DynamicProperty class but I really want to avoid this because of the no-cache issue.

Suggestions anyone?

Was it helpful?

Solution

AFAIK the only way to do this is with the DynamicProperty class. If you look at the documentation on the indexer property on the PageData object it says:

Note! Using this indexer will use the Pre and Post handlers for property lookup. I e return values are not guaranteed to belong to the page, but may be dynamic properties, "fetch-data-from"-data etc. To get data guaranteed to belong to this page, use the GetValueand SetValue methods.

Also note that setting values with this indexer will only set values that acually belong to the page, i e you may get a valid value by reading from the indexer, but trying to set a new value for the same index may yield an exception since the value does not exist in the page.

You will need to use the DynamicProperty class:

DynamicProperty myDynProp = DynamicProperty.Load(CurrentPage.PageLink, "PropertyName");
myDynProp.PropertyValue.Value = "new value";
myDynProp.Save();

Alternatively, you could circumvent the Dynamic Property using an idea Joel discusses here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top