I have the following view:
<h2>enter the student name to search</h2>
@using (Html.BeginForm())
{
<label>Search:</label>
<input type="text" name="searchString" />
<input type="submit" name="submit" />
}
and the view corresponds to following controller
namespace Searching.Controllers
{
public class SearchController : Controller
//somecode
[HttpPost]
public ActionResult SearchIndex(FormCollection formCollection)
{
string searchString=formCollection["searchString"];
var search = from m in db.Searches select m;
if (!String.IsNullOrEmpty(searchString))
{
search = search.Where(s => s.Name.Contains(searchString));
}
return View(search);
}
}
}
the controller name is SearchController.cs and the name of the method to pass form is SearchIndex.
What should be the parameter inside the Html.BeginForm().I am a begginer.
You should read this: http://msdn.microsoft.com/en-us/library/dd410596.aspx