I have a MVC 5 website that displays log file entries in a grid and provides a search capability. I have both the search criteria and the grid.mvc grid on the Index page. When the user enters the search criteria and clicks the submit button I want the ProcessLogEntries method (below) to update the Model and refresh the Index.cshtml page - not navigate to a non-existent ProcessLogEntries page!
Basically, I want this application to behave like an Single Page Application...
How do I set up the HomeController.ProcessLogEntries() method to accomplish this?
public class HomeController : Controller
{
public LogsResearchViewModel ViewModel { get; set; }
public HomeController()
{
ViewModel = new LogsResearchViewModel();
}
public ActionResult Index()
{
ViewBag.Message = "";
return View(ViewModel);
}
[HttpPost]
public ActionResult ProcessLogEntries(string txtSearchFor, string txtDateStart, string txtDateStop, string txtSource)
{
ViewBag.Message = "";
string searchFor = txtSearchFor.ToString();
DateTime start = DateTime.Parse(txtDateStart.ToString());
DateTime stop = DateTime.Parse(txtDateStop.ToString());
string source = txtSource.ToString();
ViewModel.GetProcessLogEntries(searchFor, start, stop);
ViewModel.GetErrorLogEntries(source, searchFor, start, stop);
return View(ViewModel);
}
}