Reputation: 257
Am trying to add dynamic actionlink like below but am unable to pass the exact value please help me.
@foreach(var item in ViewBag.SubmenuItems)
{
<div style="padding:10px;" class="col-md-12">
<a href="@Url.Action("[email protected]+","[email protected]+")"
style="font-weight:bold;color:crimson">@item.Name >></a>
</div>
}
Upvotes: 0
Views: 790
Reputation: 62488
You are almost there, you do not need to use +
sign which is for concatenation, as Url.Action
method only needs string
type parameters for the overload you are using, do like:
<a href="@Url.Action(item.Action,item.Controller)"
This would work fine if the Action
and Controller
property are of type string
, assuming that they are string
as you were doing concatenation.
Hope it helps!
Upvotes: 2