I have view and it has two button which are ‘Yes’ and ‘No’.
If I click ‘Yes’ redirect one page and if I click ‘No’ redirect to another page.
This is my view.
@using (Html.BeginForm())
{
<table >
<tr>
<td >
Ceremony :
</td>
<td>
Ceremony at @Model.ceremony_date
</td>
</tr>
<tr>
<td >
Name :
</td>
<td >
@Model.first_name @Model.middle_name @Model.last_name
</td>
</tr>
<tr>
<td colspan="2" >
@Html.Partial("_DegreeDetailsByGraduand", @Model.DegreeList)
</td>
</tr>
<tr>
<td colspan="2" >
IS information is correct ?
</tr>
<tr>
<td>
<input type="submit" id="btndegreeconfirmYes" name="btnsearch" class="searchbutton" value="Yes" />
</td> <td>
<input type="submit" id="btndegreeconfirmNo" name="btnsearch" class="searchbutton" value="No" /></td>
</tr>
</table>
}
This is my controller
[HttpPost]
public ActionResult CheckData()
{
return RedirectToRoute("detailform");
}
I don’t know how to get the button value in controller.
How can I do it.
Give your submit buttons a name, and then inspect the submitted value in your controller method:
}
Hope this helps: