I have 3 actionResults in one controller, and I want all actionResults return one view as the code below:
In controller:
public ActionResult Index()
{
return View(ListGroup);
}
[HttpPost]
public ActionResult Index(List<Group> listModel) {
@ViewBag.Success = "Update Suceess";
return View(listModel);//I set break point here
}
[HttpPost]
public ActionResult Search(Group ModelSearch) {
List<Group> listResult = ListGroup.Where(m=>m.GroupID == ModelSearch.GroupID).ToList();
return View("Index", listResult);
}
In view i have two forms:
@using (Html.BeginForm("Search", "DisplayTable"))
{
<fieldset>
<legend>Search</legend>
<input type="text" name="GroupID" />
<input type="submit" value="SEARCH" />
</fieldset>
}
@using (Html.BeginForm("Index", "DisplayTable", FormMethod.Post))
{
var i = 0;
<table>
<tr>
<td>Name</td>
<td>GroupID</td>
</tr>
@foreach(var item in Model){
<tr>
<td>@Html.TextBoxFor(m => m[i].Name)</td>
<td>@Html.TextBoxFor(m => m[i].GroupID)</td>
</tr>
i++;
}
</table>
<input type="submit" value="SAVE" />
}
There are two things I want this controller to do:
Search record base on the input.
Edit record.
I put each of function to actionResult. The ActionResult Index works well, but the actionResult Search doesn't work, it didn't event go to breakpoint that I set.