In my MVC application I have several submit buttons insde one form tag. How can I indicate what exactly button hes been pressed in my controller with [AcceptVerbs(HttpVerbs.Post)]?
Thanks!
In my MVC application I have several submit buttons insde one form tag. How can I indicate what exactly button hes been pressed in my controller with [AcceptVerbs(HttpVerbs.Post)]?
Thanks!
I think this will give you what you're looking for: Multiple buttons
You basically wrap each input in its own BeginForm/EndForm and assign it to seperate action methods.
Why do you not get them to POST to different controller methods?
If they do different things that would seemt o seperate concern better
You can do a simple test for the button name since only one submit button will get posted at a time.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult MyForm (FormCollection form)
{
bool isButton1 = form.AllKeys.Contains ("Button1");
bool isbutton2 = form.AllKeys.Contains ("Button2");
...
}