我的 ajax 搜索有问题。当我向我的模型添加一些数据时,我会转到我的索引视图,在那里我使用我的 ajax-search。然后 我从输入中删除文本并提交表单,索引视图没有显示添加的数据。如何解决?
这是我的 SearchController
public ActionResult Index(string searhcString)
{
var competitions = from s in db.Competitions
select s;
if(!String.IsNullOrEmpty(searhcString))
{
competitions =competitions.Where(s => s.CompName.ToUpper().Contains(searhcString.ToUpper())
|| s.CompName.ToUpper().Contains(searhcString.ToUpper()));
}
return View(competitions);
}
索引视图
@using (Ajax.BeginForm("AjaxSearch", "Competitions",
new AjaxOptions
{
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "ajaxTable"
}))
{
<input type="text" name="q" />
<button type="submit"><img height="10" src="@Url.Content("~/Images/findBtn.png")" /></button>
}