有多个参数的ActionLink [英] ActionLink with multiple parameters
本文介绍了有多个参数的ActionLink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建像 /名称=麦克白&放一个URL;年= 2011
我的 ActionLink的
我已经尝试过做像这样:
I want to create a URL like /?name=Macbeth&year=2011
with my ActionLink
which I have tried doing like so:
<%= Html.ActionLink("View Details", "Details", "Performances", new { name = item.show }, new { year = item.year })%>
,但它不工作。我该怎么做呢?
but it doesn't work. How do I do this?
推荐答案
您所使用的过载,使年
价值链接的HTML属性结束(检查您呈现源)。
The overload you are using makes the year
value end up in the html attributes of the link (check your rendered source).
超载签名如下所示:
MvcHtmlString HtmlHelper.ActionLink(
string linkText,
string actionName,
string controllerName,
object routeValues,
object htmlAttributes
)
您需要把你的两个路由值在像这样的 RouteValues
词典:
You need to put both your route values in to the RouteValues
dictionary like this:
Html.ActionLink(
"View Details",
"Details",
"Performances",
new { name = item.show, year = item.year },
null
)
这篇关于有多个参数的ActionLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文