Page properties and inheritage


I've got some trouble figuring out how to make a proprty on a page inheritable down through the page tree. Here's the scenario:

I'm working on a banner system for our page. It includes a single top banner on the top of the pages and a list of multiple banners on the right hand side of the pages. The top banner is set through a image link-property, by selecting a picture, and the side banners is a page-property pointing to a node in the page tree containing the banners. Both of them are set in the edit mode of the start page.

My problem is that the top banner is showing in all the different pages and page types throughout the site while the  side banners only show on the start page. Both of them are in the master page but how come it's only the top banner that is inherited throughout the site?

Best regards

Jan 05, 2010 14:39

How are you populating the banners in code?

Jan 06, 2010 17:10

They are both controls fetched from the master page. The banner at the top, that works through out the site uses:

            lnkTopBanner.NavigateUrl = startPage["TopBannerLInk"] as string ?? string.Empty;

            lnkTopBanner.ImageUrl = startPage["TopBanner"] as string ?? string.Empty;

            lnkTopBanner.ToolTip = startPage["TopBannerToolTip"] as string ?? string.Empty;


Not the best looking code out there but it gets the job done. The banners on the right hand side are set with:


using System;

using EPiServer.Core;

using EPiServer;

using EPiServer.Filters;


namespace EPiServer.Templates.Public.Units.Static


    /// <summary>

    /// Creates a listing of the side banners.

    /// </summary>

    public partial class SideBanners : UserControlBase


        private string _pageLinkProperty;

        private string _imageBanner;

        private string _flashBanner;

        private string _flashHeight;

        private string _flashWidth;


        protected override void OnLoad(System.EventArgs e)




            PageData startPage = DataFactory.Instance.GetPage(PageReference.StartPage);


            imgAddSign.ImageUrl = startPage["AddSign"] as string ?? string.Empty;

            imgAddSign.AlternateText = startPage["AddSignAlt"] as string ?? string.Empty;

            epiPageList.PageLinkProperty = PageLinkProperty;


            epiPageList.Filter += this.epiPageList_Filter;





        protected void epiPageList_Filter(object sender, FilterEventArgs e)


            new FilterRandomize().Filter(e.Pages);



        /// <summary>

        /// Gets or sets the name of the page property pointing out the parent page of this page list

        /// </summary>

        /// <returns>The name of the page property pointing out the parent page.</returns>

        public string PageLinkProperty


            get { return _pageLinkProperty; }

            set { _pageLinkProperty = value; }




        /// <summary>

        /// Gets or sets the name of the property pointing out the thumbnail image for the current item in the PageList.

        /// </summary>

        /// <returns>

        /// The name of the property pointing out the thumbnail image for the current item in the PageList.

        /// </returns>

        public string ImageBanner


            get { return _imageBanner; }

            set { _imageBanner = value; }




        public string FlashBanner


            get { return _flashBanner; }

            set { _flashBanner = value; }




        public string FlashHeight


            get { return _flashHeight; }

            set { _flashHeight = value; }



        public string FlashWidth


            get { return _flashWidth; }

            set { _flashWidth = value; }



        protected string GetImage(PageData page)


            if (page[ImageBanner] != null)


                string _imgTag = "<a href=\"" + page["LinkURL"].ToString() + "\" target=\"_blank\"><img id=\"BannerPicture\" src=\"{0}\" alt=\"{1}\" /></a>";

                return string.Format(_imgTag, page[ImageBanner], page.PageName);



            if (page[FlashBanner] != null)


                string movieURL = page[FlashBanner].ToString();

                string movieHeight = page[FlashHeight].ToString();

                string movieWidth = page[FlashWidth].ToString();


                string flashCode =  "<!--[if !IE]> -->" +

                                    "<object type=\"application/x-shockwave-flash\" data=\"" + movieURL + "\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">" +

                                    "<!-- <![endif]-->" +

                                    "<!--[if IE]>" +

                                    "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\",0,0,0\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">" +

                                    "<param name=\"movie\" value=\"" + movieURL + "\" />" +

                                    "<!--><!--dgx-->" +

                                    "<param name=\"loop\" value=\"true\" />" +

                                    "<param name=\"menu\" value=\"false\" />" +

                                    "<p>This is <b>alternative</b> content.</p>" +

                                    "</object>" +

                                    "<!-- <![endif]-->";


                return flashCode;



            return string.Empty;




        protected string GetNavigationURL(PageData page)


            return page["LinkURL"].ToString();





The control is working since it renders the background of the div they are in but it just doesn't get the content that's suppose to be inside.

Edited, Jan 07, 2010 8:24

How do you assign the SideBanners.PageLinkProperty in your MasterPage? It seems like it refers to CurrentPage rather than the start page. The reason the banner works is not that the related properties are inherited (only dynamic properties are inherited), but because you explicitly read the properties from the start page (in SideBanners.OnLoad).

Jan 07, 2010 11:22

Oh, now I see the problem. Thanks for pointing it out to me!

Edited, Jan 07, 2010 11:38

You were correct with the fact that it points to current page instead of the start page, but how do I get it to get the property from the start page? I can't seem to find the line to put in. Right now it says

<%# GetImage(GetPage(EPiServer.Core.PageReference.StartPage)) %>

and that doesn't work at all.

Edited, Jan 07, 2010 12:01

I suppose that line sits inside your pagelist (epiPageList)? How is the SideBanners.PageLinkProperty assigned? If it is not set when the pagelist loads you will get nothing.

Jan 07, 2010 12:08

It's assigned as a property in the start page pagetype then by

<bm:BannersList PageLinkProperty="BannersRoot" Heading=" " runat="server" ImageBanner="ImageURL" FlashBanner="FlashURL" BannerLink="LinkURL" FlashHeight="FlashHeight" FlashWidth="FlashWidth" />

Jan 07, 2010 12:21

There's where it goes wrong. When the pagelist inside your control loads it will look for the BannersRoot property on the current page. You need to make sure the pagelist uses the startpage as source. One way would be to set the PageLink property rather than the PageLinkProperty property i.e. doing something like

epiPageList.PageLink = (PageReference)(startPage["BannersRoot"] ?? PageReference.EmptyReference);

Jan 07, 2010 12:28

Excactly, but isn't this line in the markup the line that needs to be changed? How do I change it to read from the start page?

<%# GetImage(Container.CurrentPage) %>

Jan 07, 2010 13:10

That line should be correct (using Container.CurrentPage). You tell the pagelist to read from the startpage, that means it will go through the children of the start page and list them, and for each item in the list call your GetImage on the pagedata object.

Jan 07, 2010 13:14

But even when I add epiPageList.PageLink = (PageReference)(startPage["BannersRoot"] ?? PageReference.EmptyReference); it only works on the start page. This is starting to get really confusing... :)

Jan 07, 2010 13:28

Have you removed PageLinkProperty = "BannersRoot" from the markup? PageLinkProperty takes precedence over PageLink so nothing will change if you have both set. Sorry I forgot to mention this.

Jan 07, 2010 13:31

Maybe you shouldn't need, if I just got to thinking. Thanks again! This will do for now. Next step, further down the road that is, will be to be able to set different banner listings in different branches of the page.

Jan 07, 2010 13:49