I have a problem with this code, any help is appreciate the error code is Object reference not set to an instance of an object.
I try to get the value from a document types from home page and put in masterpage.
Hi,
I found the issue, I have to change the instuctions
From Pagehome headerHomePage = currPage.Descendant<Pagehome>();
To Pagehome headerHomePage = (Pagehome)homePage;
now everything work fine.
Master template
I have a problem with this code, any help is appreciate the error code is Object reference not set to an instance of an object. I try to get the value from a document types from home page and put in masterpage.
IPublishedContent homePage = Model.Content.AncestorOrSelf(1); IPublishedContent currPage = Model.Content; Pagehome headerHomePage = currPage.Descendant
int headerType = (headerHomePage.HeaderHomeType == null) ? -1 : (int)headerHomePage.HeaderHomeType; string headerTypeStr = (headerType == -1) ? "Static Sticky" : umbraco.library.GetPreValueAsString(headerType);
Hi Davide,
I think headerHomePage can be null.
Can you share all code?
no, because I tried, but here the code the View is a master Template: `
Hi, I found the issue, I have to change the instuctions
From
Pagehome headerHomePage = currPage.Descendant<Pagehome>();
ToPagehome headerHomePage = (Pagehome)homePage;
now everything work fine.
Hi Davide,
Glad that you solved the issue.
Have a nice evening!
Thanks
/Alex
is working on a reply...