How do I grab a property from the homepage for child pages
I have a master page and I want to display the footerText property of the homepage in the footer of the masterpage. This works fine for the homepage but child pages display nothing as I imagine the property does not appear on these and so the masterpage can not get hold of it.
How do I get hold of the footerText property in the homepage and display it correctly in the masterpage so that is shows on all child pages?
this should give you an idea of how to achieve this:
@Model.AncestorOrSelf<HomePage>().FooterText
Assuming your homepage has doctype "HomePage" and current content is a child from your homepage.
If you have problems using this, please provide some information about your structure.
Compiler Error Message: CS1503: Argument 1: cannot convert from
'method group' to 'HelperResult'
The home page is the root page and the page I am trying to display on is a direct child of the homepage. They are the only 2 pages in the site at the moment.
How do I grab a property from the homepage for child pages
I have a master page and I want to display the footerText property of the homepage in the footer of the masterpage. This works fine for the homepage but child pages display nothing as I imagine the property does not appear on these and so the masterpage can not get hold of it.
How do I get hold of the footerText property in the homepage and display it correctly in the masterpage so that is shows on all child pages?
Hi Lee,
this should give you an idea of how to achieve this:
Assuming your homepage has doctype "HomePage" and current content is a child from your homepage. If you have problems using this, please provide some information about your structure.
I hope this helps,
~ Jonathan
I have just tried that code as follows
I get the following error
The home page is the root page and the page I am trying to display on is a direct child of the homepage. They are the only 2 pages in the site at the moment.
Hi Lee,
in Razor you are not able to use generic types directly like this. Try following:
~ Jonathan
Awesome thanks. That works a treat!
is working on a reply...