Parent not accessible when previewing changes

Topics: Developer Forum
Nov 25, 2008 at 3:26 PM
I think I have found a defect. When editing an item, if I click "Preview changes" I am given a null reference exception when the page attempts to access its parent.

Is there a way around this or a fix available?
Nov 25, 2008 at 7:11 PM
The preview shows the previous version of an item. In these the parent reference is removed.

A workaround is this: CurrentPage.Parent ?? CurrentPage.VersionOf.Parent

I'm not exactly sure how changing this would affect queries and associations. Is the workaround enough for you?
Nov 30, 2008 at 2:56 PM
> CurrentPage.Parent ?? CurrentPage.VersionOf.Parent

This will work for me. I added a property to my base content class called SafeParent which encapsulates this.

I'm still not that familiar with N2 architecture, so this may be necessary however at first glance it appears to be a minor design flaw.