I am developing a C# MVC Application. I have an Index Action that doubles as the GET and POST Action. In the View, the user is able to search by Project Name or Number (or any other different options).
<tr>
<th>
Find by Name:
</th>
<th>
@Html.TextBox("NameSearchString", ViewBag.CurrentNameFilter as string)
</th>
<th>
<input type="submit" value="Search By Name" name="searchButton" />
</th>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<th>
Find by Project Number:
</th>
<th>
@Html.TextBox("NumberSearchString", ViewBag.CurrentNumberFilter as string)
</th>
<th>
<input type="submit" value="Search By Number" name="searchByNumber" />
</th>
</tr>
Is it possible to inspect the value of "searchButton" in the Controller via the Request.Form?
In the Controller I currently have:
// GET: PROJECTS
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index(string sortOrder, string currentNameFilter, string currentNumberFilter, string nameSearchString, string numberSearchString, int? page,
string searchButton, bool? activeProjectsOnly = true)
{
When I click on the "Search By Name" button, in the Controller the "searchButton" string ="Search By Name". That is expected, but how come I am not able to inspect it using:
this.HttpContext.Request.Form["searchButton"]
This is the MVC Level:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" />
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
Any help will be greatly appreciated.