我有一个表格中定义为提交表单视图到控制器
using (Html.BeginForm("Index", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
这种形式我的形式视图contins若干类型的按钮输入和按钮的
<input type="submit" value="val1" name="action">
<input type="submit" value="val2" name="action">
<input type="submit" value="val3" name="action" />
<button class="button" type="submit" name="action" value="val4">Val4</button>
我有2个控制器,用于这种观点
Public ActionResult form{
}
和
[HttpPost]
public ActionResult form(String button)
{
switch (actionType)
{
case "val1":
return RedirectToAction("AnotherView");
case "val2":
return RedirectToAction("AnotherView2");
default:
return RedirectToAction("AnotherView3");
}
}
但无论按钮我点击,我被重定向到主页的形式定义
using (Html.BeginForm("Index", "Home",
我的问题是如何解决这个问题,我怎么能肯定的是,这个帖子的方法,势必我刚刚输入了什么?
无论动作值如何,都会进入编辑方式 – jpo
提交表单后是否出错? – heriawan
没有错误。它只是转到我的控制器的action_name方法。顺便说一句,你是什么意思由action_name和控制器名称在“使用(Html.BeginForm(”action_name“,”控制器名称“...”。你的意思是action_name =方法名= form(对于我的例子)和controllername = HomeController这是我的表单方法的控制器的名称)? – jpo