即时通讯使用Kendo在MVC中创建自动完成搜索框,这是即时通讯在做的事情:
控制器
private CentralEntities DB = new CentralEntities();
public ActionResult Index()
{
return View();
}
public JsonResult IndexSearch()
{
//List of parks and turbines while searching
var turbineWindparkList=(from d in DB.Accessinfo
select new OverViewAutoComeplete {
ParkName=d.windpark_name,
TurbineName=d.turbine_name
})).ToList();
return Json(turbineWindparkList, JsonRequestBehavior.AllowGet);
}
}
视图
<div><input id="inputAutoComplete" /></div>
<script type="text/javascript">
@(Html.Kendo().AutoComplete()
.Name("inputAutoComplete") //The name of the AutoComplete is mandatory. It specifies the "id" attribute of the widget.
.DataTextField("ParkName") //Specify which property of the Product to be used by the AutoComplete.
.DataSource(source =>
{
source.Read(read =>
{
read.Action("IndexSearch", "Overview"); //Set the Action and Controller names.
})
.ServerFiltering(true); //If true, the DataSource will not filter the data on the client.
})
)
</script>
当我运行应用程序时,不是加载页面,而是使用自动完成搜索框,而是弹出窗口,询问我是否要保存列表的json结果!问题出在哪里?