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):
@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
see msdn
看来您已经颠倒了论点。
@Html.ActionLink("Cancel", "Index", "Forum", new{@id=ViewBag.parent_id }, new { @class = "btn"})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.