Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Problems saving property to childpage



Im using epi 5sp2 and i got a page which is a newslist and under it i got pages that are newsitems. The hierarchy of the structure is Startpage-newslist-newsitem. The problem is when i set properties of a property at the newslist the newsitem should retrieve it and display the value at the page. Ive done this by getting a pageref to the newslist at the newsitem page by :

1. PageReference ParentRef = PageReference.ParseUrl(CurrentPage["pagereftoparent"as string);

2. If not null then

3.checking that something excists

4. PageData Parent = DataFactory.Instance.GetPage(ParentRef);

5. check that its not null and if its not null

6. PageData Page = CurrentPage.CreateWritableClone();

   Page["SocialMedia"] = Parent["SocialMedia"];  //property on parent is saved to a property on    Page

   DataFactory.Instance.Save(Page, EPiServer.DataAccess.SaveAction.ForceCurrentVersion);


The whole event is triggered at the saved Event and im following the instructions of how to save one page's property to another page's property but i get the following errors/faults:


1. the property doesnt get saved to newsitem page. When i make the value visible its empty.

2. When i save Newslist page a second time and it contains newsitem it says that the pageref is empty and i get error. Despite that im checking if the value of the pageref is null or empty.


Ok so im following the textbook practice of how to save a property in code behind but it just wont do and frankly there isnt much documented about it.So if someone has a solution or could point me in a direction it would be much appriciated.

Dec 14, 2010 14:55

Do you have to save the value from the newslist on the actual newsitem?

Dec 14, 2010 15:51

I'm not sure if you can save the page with that saveaction. You must put it together with SaveAction.Save or SaveAction.Publish, like so: SaveAction.ForceCurrentVersion | SaveAction.Publish. To be able to save a current version yo must also get the specific version of the page. Dig it out using PageVersion.List(pageRef);

Dec 14, 2010 15:56

@Per Nergård

hmm, not sure that i HAVE to save it on the newsitem page. Im guessing that i could just show the value, dont know which to prefer!?


@Magnus Paulsson

ok, will try that. strange that i have to go away from what the "textbook" says (atleast the material i have). perhaps poor dokumentation?

Will let you know how it went...

Dec 15, 2010 8:45

I would definetely just get the value from the parent page.

Some pseudo code:

parent = GetPage(NewsItempage.ParentLink);

if (parent != null && parent["propertyname"] != null)

return parent["propertyname"]

Dec 15, 2010 8:49

I didn't read very carefully, I focused on the SaveAction part. And yes, you need to combine the ForceCurrentVersion with Save or Publish, not as sure about the version thing though now that you say you've seen a different example. Where did you find that.

Otherwise I agree with Per, don't duplicate the data if you have a way to get it from the newslist. If you are just going to display it you can also use the episerver Property control and set its PageLink property to make it read from a different page, for example:

<EPiServer:Property runat="server" PropertyName="MyProp" PageLink='<%#CurrentPage.ParentLink%>' />

Dec 15, 2010 9:03

hmm, ok well the best choice is to go with the Property control, but ill use the code behind for other selection ill have to make.

However im using: 



EPiServer:Property runat="server" PropertyName="SocialMedia" PageLink='<%#CurrentPage.ParentLink%>' DisplayMissingMessage="false" />

but the panel is still empty and ive set the property values in parent page. The property on the parent page is a custom made property, will this effect the output?

Dec 15, 2010 10:05

Sorry, it is using databinding syntax so you need to give the control an ID and call DataBind() on it from codebehind. Or you could set the PageLink property from CodeBehind. If you want the parent page you can also get away with just markup if you use the PageLinkProperty property cleverly:



EPiServer:Property runat="server" PropertyName="SocialMedia" PageLinkProperty="PageParentLink" />

Dec 15, 2010 10:15

Magnus youre a saint and perhaps epi god. Well the easiest way to do it is to use the last suggestion you had, without adding code behind. If you are going to do more advanced stuff then perhaps code behind is to prefer and use Per's contribution but this is simple enough...


cheers all and thnx for the help.

Dec 15, 2010 10:34
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.