检索MVC 3 id在视图中获取值(Retrieve MVC 3 id Get Value in View)
对于我的取消链接,这基本上使用户回到他们以前的页面,我无法弄清楚如何将URL中传递的id值放入ActionLink
所以说我在这里: http:// localhost:54636 / Project / AddCodeSample / 2
并在表单的底部,我有一个取消或返回按钮,我怎样才能从URL中获得该id值并将其放入ActionLink
@Html.ActionLink("Cancel", "Details", new { id = ??? })For my cancel link, which just basically takes the user back to the page they were at previously, I cannot figure out how to place the passed id value from the URL into the ActionLink
So say I'm here: http://localhost:54636/Project/AddCodeSample/2
and at the bottom of the form, I have a cancel or back button, how can I get that id value from the URL and put it in the ActionLink
@Html.ActionLink("Cancel", "Details", new { id = ??? })最满意答案
从RouteData获取id
@Html.ActionLink("Cancel", "Details", new { id = ViewContext.RouteData.Values["ID"] })get the id from the RouteData
@Html.ActionLink("Cancel", "Details", new { id = ViewContext.RouteData.Values["ID"] })更多推荐
id,URL,ActionLink,cancel,电脑培训,计算机培训,IT培训"/> <meta name="desc
发布评论