在asp.net中使用Jquery自动完成文本框 [英] Jquery autocomplete textbox in asp.net

查看:61
本文介绍了在asp.net中使用Jquery自动完成文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在asp.net中实现jquery自动完成文本框。但我收到错误对象不支持此属性或方法,虽然编码我在intellisense中获得'自动完成'功能。我试图使用谷歌api链接以防我的jquery文件没有正确加载,但我得到相同的错误。以下是我的代码:



I am trying to implement jquery autocomplete textbox in asp.net. But I am getting the error "Object doesn't support this property or method" though while coding I am getting 'autocomplete' function in intellisense. I have tried to use google api link as well in case my jquery files are not getting loaded correctly, but i am getting the same error. Following is my code:

<pre lang="HTML"><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">  

   <script src="Scripts/jquery-1.11.2.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui.js" type="text/javascript"></script>        
    <link href="Styles/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" type="text/JavaScript">
        $(document).ready(function () {

            $("[id*=txtPCTrx]").autocomplete({                    
                    source: function (request, response) {
                        $.ajax({
                            url: "PCAdd.aspx/GetAutoCompleteData",
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json; charset=utf-8",
                            data: "{'txt':'" + $('[id*=txtPCTrx]').val() + "'}", //json to represent argument
                            dataFilter: function (data) { return data; },
                            success: function (data) {
                                response($.map(data.d, function (item) {
                                    return {
                                        label: item,
                                        value: item
                                    }
                                }))
                                //debugger;
                            },
                            error: function (result) {
                                alert("Error");
                            }
                        });
                    },
                    minLength: 1,
                    delay: 1000
                });
</script>





除了上面的自动完成功能外,我还有很多其他的jquery函数可以在同一页。请帮助。



Apart from the above autocomplete function I have many other jquery functions which are working properly in the same page. Please help.

推荐答案

document )。ready( function (){
(document).ready(function () {


[id * = txtPCTrx ])。autocomplete({
source: function (request,response){
("[id*=txtPCTrx]").autocomplete({ source: function (request, response) {


。 ajax({
url: PCAdd.aspx / GetAutoCompleteData
type : POST
dataType: json
contentType: application / json; charset = utf-8
da ta: {'txt':' +
.ajax({ url: "PCAdd.aspx/GetAutoCompleteData", type: "POST", dataType: "json", contentType: "application/json; charset=utf-8", data: "{'txt':'" +


这篇关于在asp.net中使用Jquery自动完成文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆