@model IEnumerable<ModelClass.DhoniRegistry>
@using (@Html.BeginForm())
{
<b> Dhoni Name </b>
@Html.TextBox("SearchTerm", null, new { id = "txtSearch" })
<input type="submit" value="Search" />
}
<link href="~/Content/jquery-ui.min.css" rel="stylesheet" />
<link href="~/Content/jquery-ui.structure.min.css" rel="stylesheet" />
<link href="~/Content/jquery-ui.theme.min.css" rel="stylesheet" />
<script src="~/Scripts/external/jquery/jquery.js"></script>
<script src="~/Scripts/jquery-ui.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$(function ()
{
$("#txtSearch").autocomplete({ source: '@Url.Action("ASDhoniName")' });
});
</script>
Controller
public JsonResult ASDhoniName(string SearchTerm)
{
DhoniRegistryBusinessSer dhoniBisSer = new DhoniRegistryBusinessSer();
List<string> dhoniReg;
dhoniReg = dhoniBisSer.ListDhoniRegistry().Where(x => x.DhoniName.StartsWith(SearchTerm))
.Select(y => y.DhoniName).ToList();
return Json(dhoniReg,JsonRequestBehavior.AllowGet);
}
You're missing/wrongly placed jQuery/ jQuery UI.js/ autocomplete.js
files. Also you have added two copies of jquery-ui
. Remove one.
Here's the order to include files
Add the following before autocomplete
<script src="http://code.jquery.com/jquery-1.9.1.js />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.