I have a view, which consists of 3 partial views of 2 parts at the top left and right of the screen. Each of them has a mutually exclusive search, and each answer returns to its own action.
This is an action that displays the initial view.
public ActionResult Index() { var model = new SearchOptionsViewModel(); return View(model); }
This message is for one of the partial views:
[HttpPost] public ActionResult SearchByUser(UserSearchOptionsViewModel model) { if(ModelState.IsValid) { var list = SearchUserService.SearchByValue(model.LastName, model.Username, model.EmailAddress); if(list != null) { var resultsModel = new UserSearchResultsListViewModel(); list.ForEach(item => resultsModel.Users.Add(new UserSearchResultsViewModel(item))); return RedirectToAction("SearchResults", resultsModel); } } return View(model); }
This model successfully publishes and receives my data from the database and adds it to the viewmodel. I have lost information on how to show results on one screen under the search criteria.
This action, which I was hoping for, will work to get the model from the previous action and make a partial inverse to the original form. I thought that using the third search query, SearchResults, was the answer, but that didnβt work, it translates to its own page, showing the results, and not on one page.
public ActionResult SearchResults(UserSearchResultsListViewModel model) { return PartialView(model); }
A model always comes as null when I do this. I am missing something fundamental here ... How do I get this data to display on the same view?
source share