We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Try to create a menu as a partial load in the _layout based on data in a database but it doesn't show the menu.

Thread ID:





150721 Jan 17,2020 03:20 AM UTC Jan 23,2020 11:13 AM UTC ASP.NET Core - EJ 2 4
Tags: Menu Bar
Asked On January 17, 2020 03:20 AM UTC

I have the following partial view:
@model StudentUnion0105.Controllers.PartialController
    <div class="menu-control"><ejs-menu id="menuInTop" items="ViewBag.menuItems2"></ejs-menu></div>

The following script in the _Layout:

and the following div in the _Layout:
    <div id="TopMenu"></div>

The controller for the partial view is:
        public async Task<IActionResult> TopMenu()

            var CurrentUser = await userManager.GetUserAsync(User);
            var DefaultLanguageID = CurrentUser.DefaultLanguageId;

            var parameter = new SqlParameter("@LanguageId", DefaultLanguageID);

            var TopMenu1List = _context.ZdbTopMenu1.FromSql("PartialTopMenu1 @LanguageId", parameter).ToList();

            List<MenuItem> menuItem1List = new List<MenuItem>();
            foreach (var TopMenu1 in TopMenu1List)
                menuItem1List.Add(new MenuItem
                    Text = TopMenu1.MenuName,
                    IconCss = TopMenu1.IconCss,
                    Url = TopMenu1.MenuController,
                    Items = new List<MenuItem>()
                    new MenuItem { Text= "Open", IconCss= "em-icons e-open", Url= "Home/Open" },
                    new MenuItem { Text= "Save", IconCss= "e-icons e-save", Url= "Home/Save" },
                    new MenuItem { Separator= true },
                    new MenuItem { Text= "Exit", Url= "Home/Exit" }


using Syncfusion.EJ2.Navigations;

First level of the menu is coming from the database, second level for testing is hardcoded.

Further, when I debug on the partial view:
            ViewBag.menuItems2 = menuItem1List;
            return PartialView();

I see that the viewbag will have values. See image attached.

I did all kind of scenarios Some getting more results than others but no menu. (some had the div tag from the partial view.). At one time I had a UL tag but no IL.

Any suggestions what to do?



Attachment: ViewBag_d9ff57b9.zip

Arunkumar Devendiran [Syncfusion]
Replied On January 22, 2020 06:36 PM UTC

Hi Peter, 
Thank you for contacting Syncfusion support. 
We have created the sample for your reported query in that we have add the our menu component in Partial_View.cshtml (Views/Home) and by referring <partial name="../Home/Partial_View.cshtml"/> tag in layout page we have achieved your requirement. Could you please check the below sample and let us know whether this is fulfilling your requirement, if not please share us more information regarding this. If possible, please replicate your issue in below sample and revert to us. So, that we can analyze based on that and provide you a better solution. The information provided would be great help for us to proceed further. 
Sample Link: 
Arunkumar D 

Replied On January 23, 2020 09:17 AM UTC

Hi Arunkumar,

I will check it out and let you know.

Thanks very much.


Replied On January 23, 2020 09:57 AM UTC

Hi Arunkumar,

Thanks for the sample, I got it working now also in my environment. I am really impressed by the support from SyncFusion. By the way, I am building an platform for communities who want to improve the environment / sustainability.

Kind regards,


Saranya Dhayalan [Syncfusion]
Replied On January 23, 2020 11:13 AM UTC

Hi Peter 
We are glad that our sample worked in your environment. 
Saranya D 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon