Click here to Skip to main content
15,903,848 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i need autocomplete textbox like facebook search but doesn't need photo,am using this code its working but i am include this code to my project and i got the error has no method auto complete
C#
search.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    protected void Submit(object sender, EventArgs e)
    {      
        lblParticular.Text = Request.Form[txtSearch.UniqueID].ToString();
        lblStockId.Text = Request.Form[hfStockId.UniqueID].ToString();
    }

    [WebMethod]
    public static string getItem(string Search, string StockId)
    {
        string Item="";
        bl_M_StockCreation obj = new bl_M_StockCreation();
        string[] itemArr = StockId.Split('_');
        DataSet dsStock = obj.getItem(Search, itemArr[0]);
        if (dsStock.Tables[0].Rows.Count != 0)
        {
            dsStock.Tables[0].TableName = "StockDetails";
            Item = dsStock.GetXml();
        }
       
        return Item;
    }
}

C#
Service.asmx

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Script.Services;
using System.Data;

/// <summary>
/// Summary description for Service_CS
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService {

    public Service () {
    }

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string[] GetParticular(string prefix)
    {
        List<string> Particulars = new List<string>();
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;

            using (SqlCommand cmd = new SqlCommand("[USP_M_Test]"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Search", prefix);
                cmd.Parameters.AddWithValue("@intMode", 1);
                cmd.Connection = conn;
                conn.Open();
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        Particulars.Add(string.Format("{0}-{1}", sdr["Particulars"], sdr["StockId"]));
                    }
                }
                conn.Close();
            }
            return Particulars.ToArray();
        }
    }




}

pls help me
Posted
Updated 20-Oct-13 20:31pm
v3
Comments
CodeBlack 21-Oct-13 2:32am    
can you update your question with actual error message ?
athira Paramesh 21-Oct-13 2:58am    
has no method auto complete this error shows in asp page
CodeBlack 21-Oct-13 4:15am    
can you post your design code ?
ridoy 21-Oct-13 2:34am    
what is the error?
athira Paramesh 21-Oct-13 3:38am    
Uncaught TypeError: Object [object Object] has no method 'autocomplete'

1 solution

u have add this function in aspx
C#
$(document).ready(function() {
        
    $.ajax({
        type: "POST",
        url: "/Service/Service.asmx/getItem",
        dataType: "json",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        success: function(data) {
            var datafromServer = data.d.split(":");
            $("[id$='txtautofromDB']").autocomplete({
                source: datafromServer
            });
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
           alert(textStatus);
        }
    });
}

Hope this link will help us to solve your issue
3 Different Approaches for Implementing the JQuery Autocomplete with ASP.NET[^]
 
Share this answer
 
v3
Comments
athira Paramesh 21-Oct-13 6:22am    
hai ranjith,
thanks for your code bt its not working in ma form
ranjith_krishna 23-Oct-13 1:50am    
Can you please post your aspx code and error message?
athira Paramesh 23-Oct-13 2:34am    
<script type="text/javascript">
function addRow(str) {
var aa=$("[id*=gvstockOut]input[type=text][id*=txtParticulars]").val();

$("[id*=gvstockOut]input[type=text][id*=txtParticulars]").autocomplete({


source: function (request, response) {

$.ajax({

type: "POST",

contentType: "application/json;charset=utf-8",

url: "Service.asmx /GetParticular",

data: "{'prefix':'" + aa + "'}",

dataType: "json",

success: function (data) {

response(data.d);
},

error: function (result) {

alert("Error");
}
});

}
});
}
</script>

error the same uncaught type error:object#<object>has no method autocomplete

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900