【发布时间】:2014-09-10 10:36:32
【问题描述】:
我想创建一个自定义操作链接,但我不知道如何在满足我的需求的同时执行此操作。我之前使用过自定义 htmlhelpers,但这对我来说有点棘手。
我要调用的actionlink需要是这样的:
@Html.CustomActionLink("LinkText", "Area","Controller","TabMenu","Action",routeValues, htmlAttributes)
例如:
@Html.CustomActionLink("Click here","Travel","Trip","Index","Index", new { par1 = "test", par2 = test2, new { @class = "font-color-blue" })`
会生成这个 html:
<a class="font-color-blue" href="/Trip/Travel/Index/Index?par1=test&par2=test2">Click Here</a>
我的路线如下:
context.MapRoute(
"EPloeg_default",
"EPloeg/{controller}/{tabmenu}/{action}/{id}/{actionMethod}",
new { action = "Index", id = UrlParameter.Optional, actionMethod = UrlParameter.Optional }
);
有什么办法可以做到这一点吗?
【问题讨论】:
-
那会生成什么 html?
-
不好意思忘记了,在问题里加了!
标签: asp.net-mvc asp.net-mvc-4 html-helper actionlink