Lots of ways to do this, but the gist is that you need to render your partial view from an action that you pass the search term to.
Anyway, he's a rough example
models
public class SearchTerm
{
public string SearchID { get; set; }
public string SearchText { get; set; }
}
public class SearchModel
{
public string SearchValue { get; set; }
public SelectList SearchTerms { get; set; }
}
index.cshtml
@model Models.SearchModel
@using(Html.BeginForm())
{
<p>
@Html.DropDownListFor(m => m.SearchValue, Model.SearchTerms)
</p>
<p>
<input type="submit" value="Search"/>
</p>
}
@if(Model != null)
{
@Html.Action("Search", "Home", new { searchTerm = Model.SearchValue })
}
_searchResults.cshtml
@model List<string>
@if(Model == null)
{
return;
}
@foreach(string result in Model)
{
<div>@result</div>
}
Controller
private SelectList GetTerms()
{
return new SelectList(new List<SearchTerm>
{
new SearchTerm{SearchID="1", SearchText="One"},
new SearchTerm{SearchID="2", SearchText="Two"},
new SearchTerm{SearchID="3", SearchText="Three"}
}, "SearchID", "SearchText");
}
[HttpGet]
public ActionResult Index()
{
SearchModel model = new SearchModel();
model.SearchTerms = GetTerms();
return View(model);
}
[HttpPost]
public ActionResult Index(SearchModel model)
{
model.SearchTerms = GetTerms();
return View(model);
}
public ActionResult Search(string searchTerm)
{
if (string.IsNullOrWhiteSpace(searchTerm))
{
return new EmptyResult();
}
List<string> results = new List<string> { "Result 1 for " + searchTerm, "Result 2 for " + searchTerm };
return PartialView("~/Views/Home/_searchResults.cshtml", results);
}