JQuery UI Autocomplete不能运行asp.net

时间:2016-11-16 12:15:46

标签: asp.net jquery-ui jquery-ui-autocomplete

我真的很困惑为什么我的自动完成功能不起作用。你能帮助我解决这个问题的原因吗?即使是日期时间选择器也不起作用,我想知道它是否是我正在使用的模板" Gentellela Alela"。请帮助我的家伙。提前致谢

以下是代码

    <link href="Styles/bootstrap.min.css" rel="stylesheet" />
    <link href="Styles/font-awesome.min.css" rel="stylesheet" />
    <link href="Styles/nprogress.css" rel="stylesheet" />
    <link href="Styles/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" />
    <link href="Styles/daterangepicker.css" rel="stylesheet" />
    <link href="Styles/jqvmap.min.css" rel="stylesheet" />
    <link href="Styles/custom.min.css" rel="stylesheet" />
    <link href="Styles/cust.css" rel="stylesheet" />
    <link href="Styles/style.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-ui-1.12.1.js"></script>



   <script type="text/javascript">
        $(function () {
            $("#<%= txtProdCode.ClientID%>").autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: "<%:Page.ResolveUrl("~/WS/Platts.asmx/FilterItem")%>",
                        data: "{ 'filterstring': '" + request.term + "' }",
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        dataFilter: function (data) { return data; },
                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item.prDesc,
                                    value: item.prDesc
                                }
                            }))
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(errorThrown);
                        }
                    });
                },
                minLength: 2

            });
        });
    </script>

Windows服务(.asmx)

 <WebMethod()> _
    Public Function FilterItem(ByVal filterstring As String) As List(Of ProductDetail)
        Dim retEmp As New List(Of ProductDetail)
        Using secrpt As New BLL.TradingModel.TradingTransactionRepository
            retEmp = secrpt.GetAllPlattCode().Where(Function(c) c.prDesc.ToLower.Contains(filterstring)).ToList
        End Using
        Return retEmp
    End Function

存储库

Public Function GetAllPlattCode() As List(Of ProductDetail)
            Return (From _plt As ProductDetail In TradingTransactionCTX.ProductDetails Order By _plt.pID).ToList
        End Function

1 个答案:

答案 0 :(得分:0)

添加:

   <script
              src="https://code.jquery.com/jquery-2.2.4.min.js"
              integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
              crossorigin="anonymous"></script>

之前:

<script src="~/Scripts/jquery-ui-1.12.1.js"></script>

然后你可以使用任何jquery元素或命令。