0
リンクから検索機能を作りたいMVC3検索機能付アクションリンク
現在、ホームページに検索ボックスがあります。検索ボックスを操作しています。
しかし、コントローラの検索方法にいくつかのパラメータを渡す方法がわかりません。
このコーディングのように置くと、searchStringはコントローラで 'null'になります。
actionLinkを使用してserachStringパラメータを取得するにはどうすればよいですか?
お手伝いできますか?多分それは簡単に見えます。助けてください、助けてください。ありがとう。あなたはHtml.ActionLink
のための右のオーバーロードを使用していない
//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());
}