How do you handle multiple submit buttons inside the single form in ASP.NET MVC ?
Eg.
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
button type="submit" id="btnApprove" value="Approve"> Approve
button type="submit" id="btnReject" value="Reject"> Reject
}
1
Answer
How do you handle multiple submit buttons inside the single form in ASP.NET MVC ?
Eg.
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
button type="submit" id="btnApprove" value="Approve"> Approve
button type="submit" id="btnReject" value="Reject"> Reject
}
We can fetch the clicked button's value from the actionmethod Index as below.
public ActionResult Index(string btnValue)
{
if (btnValue == "Approve")
{
return "Approve Clieked";
}
else if (btnValue == "Reject")
{
return "Reject Clieked";
}
}