I have an action
public ActionResult Index(string search)
{
var listingModel = Repository.Search(search); //gets from DB items. Model doesn't include 'serach' string as property or field
return View("Index", listingModel)
}
The View contains filter area with text box (this code from extension method for helper):
htmlHelper.TextBox("Search", null, htmlAttributesDictionary);
I've noticed that it automatically inserts value of 'search' parameter into textbox. But my problem is that I cannot find how it gets it. I cannot see the source code of .TextBox() helper. I cannot find this value in htmlHelper.ViewData.Model. I want to change value of search parameter (I need to save it is Session and gets from session). Do you know what I can write in the controller action that will automatically sets my value from session into the checkbox.
I know that I can just use redirect, but it doesn't seem to be correct way. It looks for me not very beautiful:
public ActionResult Index(string search)
{
search = GetFromSession();
return RedirectToAction("Index", new {search = search});
var listingModel = Repository.Search(search); //gets from DB items. Model doesn't include 'serach' string as property or field
return View("Index", listingModel)
}