Note that there are some explanatory texts on larger screens.

plurals
  1. POautocomplete jquery asp.net c#
    text
    copied!<p>my database table TAGS(TagId,TagName) my web method code is as follows</p> <pre><code> public List&lt;Tag&gt; FetchTagList(string tag) { OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"|DataDirectory|\\ImageDB2.mdb\";Persist Security Info=True"); DataSet ds = new DataSet(); DataTable dt = new DataTable(); string query = "select * from TAGS Where TagName like '@myParameter'"; OleDbCommand cmd = new OleDbCommand(query,cn); cmd.Parameters.AddWithValue("@myParameter", "%" + tag + "%"); try { cn.Open(); cmd.ExecuteNonQuery(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(ds); } catch(OleDbException excp) { } finally { cn.Close(); } dt = ds.Tables[0]; List&lt;Tag&gt; Items = new List&lt;Tag&gt;(); Tag obj; foreach (DataRow row in dt.Rows) { obj = new Tag(); //String From DataBase(dbValues) obj.TagName = row["TagName"].ToString(); obj.ID = Convert.ToInt32(row["TagId"].ToString()); Items.Add(obj); } return Items; } </code></pre> <p>}</p> <p>i used class</p> <p>public class Tag { public int ID { get; set; } public string TagName { get; set; } }</p> <p>my javascript code is</p> <pre><code>&lt;link href="css/jquery-ui.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="jsautocom/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="jsautocom/jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt; $(function () { $(".tb").autocomplete({ source: function (request, response) { $.ajax({ url: "WebService.asmx/FetchTagList", data: "{ 'tag': '" + 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 { value: item.TagName } })) }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }, minLength: 1 }); }); &lt;/script&gt; </code></pre> <p>my aspx page is as like</p> <pre><code>&lt;div class="demo"&gt; &lt;div class="ui-widget"&gt; &lt;label for="tbAuto"&gt;Search Tag: &lt;/label&gt; &lt;asp:TextBox ID="TextBox1" class="tb" runat="server" ontextchanged="TextBox1_TextChanged"&gt;&lt;/asp:TextBox&gt; &lt;asp:Button ID="btnSearch" runat="server" CssClass="btnSearch" onclick="btnSearch_Click" Text="Search" /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>but i get nothing.how to solve it.any one helps me is greatly appreciated.thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload