0
データベースに請求書を検索する検索ボックスを作成しようとしています。検索ボックスのコードは以下の通りです:検索テキストボックスにnull値を受け取る
@using (Ajax.BeginForm("Search", "Invoice", new AjaxOptions() { HttpMethod = "POST" }))
{
<% input id="search-field" name="search" type="text" value="" %/>
<% input id="search-submit" name="search-submit" type="submit" value="" %/>
}
public ActionResult Search(FormCollection collection)
{
if (collection["search-field"] == null)
return RedirectToAction("Index");
else
{
string id = collection["search-field"].ToString();
return RedirectToAction("Details", "Invoice", id.Trim());
}
}
今の問題は、私はコントローラ検索アクションのみヌル値を受け取るということです。
私は次のアクションに文字列をキャッチしながら、私はまだ文字列値を受け取ることができませんMVC3および.NET Framework 4.0
を使用しています:
公共のActionResult詳細(文字列ID) {
if(string.IsNullOrEmpty(id))
return RedirectToAction("Index"); ==============> Here
ObjectParameter[] parameters = new ObjectParameter[3];
parameters[0]= new ObjectParameter("CUSTNMBR", id);
parameters[1] = new ObjectParameter("StartDate", System.DateTime.Now.Date.AddDays(-90));
parameters[2] = new ObjectParameter("EndDate", System.DateTime.Now.Date);
return View(_db.ExecuteFunction<Models.Invoices>("uspGetCustomerInvoices", parameters).ToList<Models.Invoices>());