Try our conversational search powered by Generative AI!

Start page properties values are not updated on child pages


Hi All,I am resusing some of my property values from start page into my other pages as reusable component.  

But when I update the value on start page its not updated on other pages .It still has the old value. Do anyone faced this issue before , some kind of caching?

Jan 18, 2016 16:35

Can you give sample code of such property which reuses Start page properties?

Jan 18, 2016 16:56

Here is an example :-

If childpage property is not set I set the StartPage Property..

ChildPage.Property = ChildPage.Property == null ?  StartPage.PropertyName :ChildPage.Property

Jan 18, 2016 17:52

And where do you run this code? In some event, controller's action or in Property's getter?

Jan 18, 2016 17:54

I override the Below Method:-

The code gets the startpage property value but after I update the update is not reflected in the property.

public override void SetDefaultValues(ContentType contentType)

LanguageHeading = !string.IsNullOrEmpty(startPage.Property["LanguageHeading"].ToString()) ? startPage.Property["LanguageHeading"].ToString() : string.Empty;

Jan 18, 2016 18:17

SetDefaultValues is called only once when the page (or other IContent) is created. It is not called when you save the page later.

Instead I suggest you to handle this in the property itself:

public class MyPage : PageData

	public string DefaultHeading = "My heading";

	[Display(Order = 20)]
	public virtual string LanguageHeading
			return this.GetPropertyValue(p => p.LanguageHeading) ?? DefaultHeading;
			this.SetPropertyValue(p => p.LanguageHeading, value);
Jan 18, 2016 18:29

Is startPage or StartPage a static variable or property? If so, that's probably the problem. You need to fetch the startpage every time, which is not a problem since it's cached.

Jan 18, 2016 20:42

Thanks Johan and Maris for the answers.


Since client has created many subsites (close to 40)  all the default values has been set on live , i.e. value from start page while creating the page during override of SetDefaultValues() method .

So properties will never be null or empty now . My requirement was  IF property is not set in Subsite for that page it should get from Startpage of the page.  Since now all the properties has some value how do I change the logic now ??


Yes I had made static property ,now I changed that . Thanks for pointing it . 

Jan 20, 2016 6:58

Now you can create ScheduledJob which goes through all pages and resets that property to null if it equals to start page property's value. It might look something like this in the ScheduledJob's Execute method:

var allPages = GetAllSitePages();

foreach(var page in allPages)
    if(page.MyProperty == startPage.MyProperty)
        page.MyProperty = null;
Edited, Jan 20, 2016 11:20
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.