简体   繁体   English

具有多个“新闻”的MVC C#ActionLink

[英]MVC C# ActionLink with multiple “news”

How do I correct this so that the ActionLink reverts to http://localsite/forum/index/4 (where 4 is defined by the parent_id as shown below): 如何纠正此问题,以便ActionLink还原为http://localsite/forum/index/4 (其中4由parent_id定义,如下所示):

 @Html.ActionLink("Cancel", "Index", "Forum", new { @class = "btn"}, new{ @id=ViewBag.parent_id })

Currently it reverts to: 目前它恢复为:

http://localhost:53731/Forum?class=btn

Thanks for your help, 谢谢你的帮助,

Mark 标记

Just invert the two last parameters : 只需反转最后两个参数:

@Html.ActionLink("Cancel", "Index", "Forum",  new{ @id=ViewBag.parent_id }, new { @class = "btn"})

routeValues should come before htmlAttributes routeValues应该在htmlAttributes之前

see msdn 参见msdn

看来您已经颠倒了论点。

 @Html.ActionLink("Cancel", "Index", "Forum", new{@id=ViewBag.parent_id }, new { @class = "btn"})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM