Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
in an umberco template i have the following code
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage@{ Layout = null; var homepageNode = CurrentPage.AncestorsOrSelf(1);}
It keeps returning "Object reference not set to an instance of an object."
I have also tried CurrentPage.AncestorsOrSelf(1).FirstOrDefault()
I've looked at lots of blog posts and cant seem to see the problem.
Can anyone point me in the right direction?
Try this:
Umbraco.TypedContentAtRoot().SingleOrDefault()
What is you currentPage. Have you checked that object to see what children and what ancestors it has? Charlie?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Why is AncestorsOrSelf returning null reference exception?
in an umberco template i have the following code
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
var homepageNode = CurrentPage.AncestorsOrSelf(1);
}
It keeps returning "Object reference not set to an instance of an object."
I have also tried
CurrentPage.AncestorsOrSelf(1).FirstOrDefault()
I've looked at lots of blog posts and cant seem to see the problem.
Can anyone point me in the right direction?
Try this:
What is you currentPage. Have you checked that object to see what children and what ancestors it has? Charlie?
is working on a reply...