Try our conversational search powered by Generative AI!

Navigation problem - SDK

Vote:
 

Hi,

I'm trying to test the documentation from Episerver SDK 6 by using the navigation MenuList.

However Visual Studio reports a compilation error. Here is the code and then the error

    protected override void OnLoad(System.EventArgs e)
    {
        base.OnLoad(e);
        Menu.PageLink = PageReference.StartPage;
        Menu.PageLoader.GetChildrenCallback = PageReference.StartPage;  // <== Error occurs.. EPiServer.Web.WebControls.HierarchicalPageLoader.GetChildrenMethod' is a  'type', which is not valid in the given context 
        Menu.DataBind();
    }

    /// 
    /// Creates the collection for the main menu, adding the startpage
    /// 
    private PageDataCollection LoadChildren(PageReference pageLink)
    {
        PageDataCollection pages = DataFactory.Instance.GetChildren(pageLink);
        pages.Insert(0, DataFactory.Instance.GetPage(pageLink));
        return pages;
    }

    /// 
    /// Gets or sets the MenuList for this control
    /// 
    public MenuList MenuList
    {
        get { return Menu; }
        set { Menu = value; }
    }

Kind regards,

Jon Haakon

 

#38692
Apr 19, 2010 10:40
Vote:
 

I managed to make it to work by

changing the line to this:

Menu.PageLoader.GetChildrenCallback = new HierarchicalPageLoader.GetChildrenMethod(LoadChildren);

However, I don't understand "LoadChildren". The funciton is supposed to take one parameter (Pagereference),

but exception occur "method name is expeced".

Someone how have a good explanation on this?

Jon Haakon

#38693
Apr 19, 2010 11:04
Vote:
 

It must be an error in the example. The GetChildrenCallback is a delegate expecting a method that conforms to methothname(Pagereferece).

When the pageloader code is run it will use the specified method instead of the builtin.

#38702
Apr 19, 2010 16:15
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.