$()自动完成不是一个功能

时间:2016-06-28 12:31:30

标签: jquery asp.net-mvc autocomplete

enter image description here以下是我要渲染的代码。我谷歌出来,发现可能有jquery订单的错误。我按照给定的方式更改了它,但这对我来说仍然无效。

@model IEnumerable<UserManagementSystem.Models.UserDetail>
@using System.Linq
@{
    ViewBag.Title = "Index";
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery-ui.js"></script>
<script type="text/javascript">

    $(document).ready(function () {
        jQuery("#SearchName").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/Home/Index",
                    type: "POST",
                    dataType: "json",
                    data: { Prefix: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.Name, value: item.Name };
                        }))

                    }
                })
            },
            messages: {
                noResults: "", results: ""
            }
        });
    })
</script>
<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p><br /><p>
    @using (Html.BeginForm("Index", "Users", FormMethod.Get))
    {
        @Html.TextBox("SearchName", "", new { @class = "control-label col-md-2", Style = "margin-right:10px;", placeholder = "Name" })
        @Html.TextBox("SearchEmail", "", new { @class = "control-label col-md-2", Style = "margin-right:10px;", placeholder = "Email" })
        @Html.DropDownList("SearchDesignation", ViewBag.DesignationList as SelectList, "Select", new { @class = "control-label col-md-2", Style = "margin-right:10px;" })  <input type="submit" value="Search" onclick="location.href='@Url.Action("Index", "Users")'" />
    }
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Contact)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Email)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Designation)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Department)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Address)
        </th>
        <th></th>
    </tr>
@if (!Model.Any())
{
    <tr><td></td><td></td><td></td><td>No Record Found</td><td></td><td></td><td></td></tr>
}
else
{
    foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contact)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Email)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Designation)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Department)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Address)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.ID }, new { onclick = "return confirm('Are you sure you wish to delete this?');" })
            </td>
        </tr>
    }
}

</table>

以上所有代码都是在mvc 4.5.2中完成的,有没有与.Net框架相关的问题?我被困在这里,现在不知道该怎么办。我还附加调试器错误图像。

0 个答案:

没有答案