c# - Autocomplete jquery not working? -



c# - Autocomplete jquery not working? -

i have text box, within want auto complete. info auto finish going given through database.

this jquery:

var info = "autocompletetagdata.aspx" $("#item").autocomplete({ source: info });

this have set in autocompletetagdata now:

protected void page_load(object sender, eventargs e) { string term = request.querystring["term"]; sqlconnection myconnection = new sqlconnection(connstr); myconnection.open(); string sql = ("select top 10 ltrim(rtrim(pgprdc)) pgprdc sroprg sroprg"); sqlcommand mycommand = new sqlcommand(sql, myconnection); stringbuilder sb = new stringbuilder(); seek { sqldatareader reader = mycommand.executereader(); if (reader.hasrows) { while (reader.read()) { sb.append(reader.getstring(0)) .append(environment.newline); } } reader.close(); } grab (exception ex) { myconnection.close(); } myconnection.close(); response.write(sb.tostring()); //return "['word', 'hello', 'work', 'oi', 'hey']"; }

what doing wrong?

edit:

<script type="text/javascript" src="/scripts/js/jquery.scrollto-min.js"></script> <script type="text/javascript" src="/scripts/js/jquery.flash.min.js"></script> <script type="text/javascript" src="/scripts/js/jquery.sifr.min.js"></script> <script type="text/javascript" src="/scripts/js/global.js"></script> <script type="text/javascript" src="/scripts/js/jquery-ui-1.8.17.custom.min.js"></script> <script type="text/javascript" src="/scripts/js/orderstatus.js"></script> <script type="text/javascript" src="/scripts/js/jquery.ui.core.js"></script> <script type="text/javascript" src="/scripts/js/jquery.ui.widget.js"></script> <script type="text/javascript" src="/scripts/js/jquery.ui.datepicker.js"></script> <script type="text/javascript" src="/scripts/js/jquery.qtip-1.0.0-rc3.min.js"></script> <script type="text/javascript" src="/scripts/js/json_parse.js"></script>

when go autocompletetagdata..aspx in browser on screen...

sc052 sc053 sc055 sc060 sc061 sc062 sc063 sg011 sg014 sg015

firebug show these items beingness sent in response, nil happens text box

this jquery code :

$("#txt1").autocomplete({ source: function (request, response){ $.ajax({ type: "post", url: "youraddress", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (data) { response($.map(data.d, function (item) { homecoming { id: item.value, value: item.text } })) } }); }, select: function (event, ui) { $("#hdnid").val(ui.item.id);//put id in hidden field } });

call ajax request , homecoming json info :

[{"value":val1,"text":"text1"}, {"value":val2,"text":"text2"}]

for homecoming somthing must define class :

public class autocomplete { private int val; private string text; public int value { { homecoming val; } set { val = value; } } public string text { { homecoming text; } set { text = value; } } }

so plenty homecoming list of class objects (list<autocomplete>).so create list , fill sqlcommand , homecoming response of xmlhttprequest

i tested it.it works great man

good luck.foroughi

c# jquery jquery-ui webforms jquery-ui-autocomplete

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -