在ASP.NET MVC中,我正在使用HTML帮助程序
Html.BeginForm("ActionName", "Controller", FormMethod.Post);
Run Code Online (Sandbox Code Playgroud)
但我需要发布到:/ controller/action/23434
我如何传递身份证?
Jon*_*and 63
马特应该工作得很好.FormMethod.Post
但是,如果你仍在传递,你需要这样做:
Html.BeginForm("action","controller", new { Id = 12345 }, FormMethod.Post);
Run Code Online (Sandbox Code Playgroud)
反转第三个和第四个参数将导致Id
被视为属性而不是路由值.
Mat*_*nze 10
Html.BeginForm("action", "controller", new {Id = 12345})
小智 7
Html.BeginForm("action", "controller", new { id = ViewBag.FileID },
FormMethod.Post, new { id = "feedbackform" })
Run Code Online (Sandbox Code Playgroud)
至于querystring,?type=golden
我不知道该怎么做.当然,查询是一种获取,并破坏了整个目的FormMethod.Post
.我的意思是,FormMethod.Get
如果你想要查询字符串数据,你可以使用,这可能就是你要找的东西.
此外,您可以html.beginform
使用表单标记手动避免和执行查询字符串,获取+发布.
第三,如果您使用表单,则可以创建隐藏字段:
[input type=hidden name="type" value="golden"]
Run Code Online (Sandbox Code Playgroud)
然后,当按下提交按钮时,值将作为表单变量正确传递.
归档时间: |
|
查看次数: |
72994 次 |
最近记录: |