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

URL action submenu

I have a problem with menu  - URL is not generated when menu  items are generated in foreach process. Am I missing something? same syntax works when adding individual items and other  properties in foreach process are also generated ok.

        public async Task<IViewComponentResult> InvokeAsync()
            List<MenuItem> mainMenu = new List<MenuItem>();
           mainMenu.Add(new MenuItem
                Id = 200,
                Text = "MasterData",
                ParentId = null,
                URL =Url.Action("Index", "MasterData")
            mainMenu.Add(new MenuItem { Id = 300, Text = "Main", ParentId = null, URL =Url.Action("Index", "Main") }); -THIS WORKS
     mainMenu.Add(new MenuItem { Id = 301, Text = "MainOther", ParentId = null, URL =Url.Action("Index", "Main", new{actionID=1}) }); - THIS WORKS
            mainMenu.Add(new MenuItem { Id = 400, Text = "Functions", ParentId = null, URL = "" });
            var functions = GetFunctions(null);
            foreach (Function function in functions)
                mainMenu.Add(new MenuItem
                    Id = function.ID,
                    Text = function.Name,
                    ParentId = 400,
                    URL = Url.Action("ExecuteAction", "Main", new { actionID =function.ID }) THIS  IS EMPTY
            return View(mainMenu);

1 Reply

PO Prince Oliver Syncfusion Team July 24, 2017 12:27 PM UTC

Hi Rein, 

Thank you for contacting Syncfusion support. 

We tried to recreate your scenario using the code snippet you provided, but we were unable to reproduce the issue you reported. We have attached the sample for your reference, kindly refer to the following link for the sample: http://www.syncfusion.com/downloads/support/forum/131654/ze/MenuCoreSample1319094655 

If the issue still persists in your end, please provide us an issue reproducible sample or modify the above sample to reproduce the issue. it will help us provide you solution. 


Live Chat Icon For mobile
Up arrow icon