如何创建从httpget获取相同参数的httppost? [英] How do I create a httppost getting same parameters from httpget?
本文介绍了如何创建从httpget获取相同参数的httppost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个控制器来显示模型(用户),并且想要创建一个只需要激活按钮的屏幕。我不想要表格中的字段。我已经在网址中有了id。我怎样才能做到这一点?
I have a controller to show up a model (User) and want to create a screen just with a button to activate. I don't want fields in the form. I already have the id in the url. How can I accomplish this?
推荐答案
您可以在表单中使用隐藏字段:
You could use a hidden field inside the form:
<% using (Html.BeginForm()) { %>
<%= Html.HiddenFor(x => x.Id) %>
<input type="submit" value="OK" />
<% } %>
或在表单的操作中传递:
or pass it in the action of the form:
<% using (Html.BeginForm("index", "home",
new { id = RouteData.Values["id"] }, FormMethod.Post)) { %>
<input type="submit" value="OK" />
<% } %>
这篇关于如何创建从httpget获取相同参数的httppost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文