我试图在Ajax.ActionLink中列出许多类别。我想动态地给出控制器名称和ActionLink名称。有没有办法做到这一点?
以下是我想插入参数的代码。
@if (ViewBag.MainList != null)
{
foreach (var item in ViewBag.MainList)
{
<option data-is-secure-trade="0" value="3530">
@Ajax.ActionLink(item.Param1,
item.Param2, new AjaxOptions {
HttpMethod = "Post" })
</option>
}
}
答案 0 :(得分:0)
您需要使用Ajax.ActionLink
@Ajax.ActionLink("Link text",
"ActionName",
new { controller = "MyController" },
new AjaxOptions { HttpMethod = "Post" })
来指定路线值:
{{1}}