I want to have a dynamic value.
I got this code but it does not work. it shows length in url instead of parameter i've given:
@model IEnumerable<WebInboxTool.Models.MenuItem>
<div>
@foreach (var item in Model)
{
@Html.ActionLink(item.Name, item.ActionName, item.ControllerName,item.Parameters, null);
}
</div>
MenuItem:
public class MenuItem
{
public string Name { get; set; }
public string ActionName { get; set; }
public string ControllerName{ get; set; }
public object Parameters { get; set; }
}
}
Layout Page where it will get rendered:
<div id="menu" class="menu">
<div class="menu-head">
<h2>Inbox Tool</h2>
</div>
@{ Html.RenderAction("MailboxMenu", "PartialMenu"); }
</div>
Seems your action link is wrong.
@Html.ActionLink("Link text", "action", "controller", new { id = something }, null)
In your case, you can do something like this.
<div>
@foreach (var item in Model)
{
@Html.ActionLink(item.Name, item.ActionName, item.ControllerName, new { id = item.Parameters }, null);
}
</div>