I want to make search function through the link.
Currently, I have search box in home page. It is working the search box.
However, I don't know how to pass the some parameters to Search method in controller.
When I put like this coding, searchString is 'null' in controller.
How can I get serachString parameter through actionLink?
Could you help me? Maybe it looks easy. Please help me or advice me. Thanks.
//mac.cshtml
<h3>CPU Processor</h3>
<ul>
<li>@Html.ActionLink("Intel Core i5", "Search", "Store", new { @searchString = "i5"})</li>
<li>@Html.ActionLink("Intel Core i7", "Search", "Store", new { @searchString = "i7" })</li>
</ul>
//Search method in StoreController
public ActionResult Search(string searchString)
{
var product = from a in _db.Product.Include(a => a.Category)
select a;
if (!String.IsNullOrEmpty(searchString))
{
product = product.Where(a => a.model.ToUpper().Contains(searchString.ToUpper())
|| a.Category.name.ToUpper().Contains(searchString.ToUpper()));
}
return View(product.ToList());
}