检索MVC 3 id在视图中获取值(Retrieve MVC 3 id Get Value in View)

编程入门 行业动态 更新时间:2024-10-28 04:23:58
检索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

本文发布于:2023-08-06 03:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1443979.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   id   MVC   Retrieve   View

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!