Search code examples
c#ef-code-firstaspnetboilerplateasp.net-boilerplate

Asp Boilerplate,,, How to create New Menu in Menu bar?


I want to add a new menu in menu bar, i created a class according to Boilerplate documents, but don't know how to configure menu,, And menu is for all users,, Here is code which i have done yet I created a class extended from navigation provider

  public class NavigationsProviderMenu : NavigationProvider
{
    public override void SetNavigation(INavigationProviderContext context)
    {
        context.Manager.MainMenu
        .AddItem(
            new MenuItemDefinition(
                "Jobs",
                new LocalizableString("Jobs", "ShipperBuyerV1"),
                url: "/JobsList",
                icon: "fa fa-tasks"
                ));
    }

}

Solution

  • You should sequentially call AddItem as a chain and all corresponding menu items will be at same level:

    context.Manager.MainMenu
        .AddItem(
            new MenuItemDefinition(
                "Jobs",
                new LocalizableString("Jobs", "ShipperBuyerV1"),
                url: "/JobsList",
                icon: "fa fa-tasks"
            ))
        .AddItem(
            new MenuItemDefinition(
                "Another",
                new LocalizableString("Another", "ShipperBuyerV1"),
                url: "/Another",
                icon: "fa fa-tasks"
            ));