I have a form in my form view defined as
using (Html.BeginForm("Index", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
This form contins a number of input of type button and button
<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>
I have 2 controllers for this view
Public ActionResult form{
}
and
[HttpPost]
public ActionResult form(String button)
{
switch (actionType)
{
case "val1":
return RedirectToAction("AnotherView");
case "val2":
return RedirectToAction("AnotherView2");
default:
return RedirectToAction("AnotherView3");
}
}
But whichever button I click, I am being redirected to the Home defined in the form
using (Html.BeginForm("Index", "Home",
My question is how can I fix this and how can I be certain that this post method is bound to my view as i just typed it in?
use input type select:
and method at controller