如何在ID传递与Html.BeginForm()? [英] How to pass in ID with Html.BeginForm()?
本文介绍了如何在ID传递与Html.BeginForm()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 ASP.NET MVC 我使用的HTML帮助
In ASP.NET MVC I'm using the HTML helper
Html.BeginForm("ActionName", "Controller", FormMethod.Post);
但我需要发布到:/控制器/动作/ 23434
But I need to post to: /controller/action/23434
我如何通过在ID?
推荐答案
马特的应该很好地工作。如果你还在传递 FormMethod.Post
,不过,你需要做的是这样的:
Matt's should work fine. If you are still passing in FormMethod.Post
, though, you need to do it like this:
Html.BeginForm("action","controller", new { Id = 12345 }, FormMethod.Post);
倒车,第三和第四个参数将导致编号
被视为一个属性,而不是路由值。
Reversing the third and fourth parameters will result in the Id
being treated as an attribute instead of a route value.
这篇关于如何在ID传递与Html.BeginForm()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文