Hi,
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);
}