使用单个BeginForm中的不同操作

时间:2014-04-03 05:20:58

标签: c# submit asp.net-mvc-5 html.beginform

我收到了一份表格,其中显示了所展示产品的详细信息。提交此表格后,它将转至" Dropshipment"我的beginformm的动作是

@using (Html.BeginForm("DropShipment", "LoadProduct", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{

然而,在编辑过程中,我使用相同的UI来允许编辑,现在当我提交时,显然它会转到" Dropshipment"再次行动。但是我希望它提交给"编辑"动作。

我怎样才能做到这一点?

以下是我的偏见 enter image description here

2 个答案:

答案 0 :(得分:0)

您可以将所需的操作字符串(“DropShipment”或“Edit”)存储在为_Partial提供的模型中的新属性中。可以在Controller中设置此操作字符串,我假设它是“LoadProduct”。然后将其插入Html.BeginForm参数。

@using (Html.BeginForm(Model.MyDesiredAction, "LoadProduct", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{

答案 1 :(得分:0)

非常感谢你的帮助。

我将Beginform放在我的Partial之外解决了这个问题。 我正在为未来的访问者发布我的解决方案。

enter image description here

干杯。