
Autocomplete not know what to tell him a textbox ‘would begin to enter a keyword, and so far have been entered in the database between the characters in the drop-down list at the bottom, offering the user a system of records. Google it is a good example. Ajax Control Toolkit for this process in the work we can see with the AutoComplete object. Ajax control tools, but one thing we add to our project and on file in the background along with a code that is included in our project, this problem may issue in large projects. From time to time in my browser to browser antin he brings problemleride blunt. Incidentally, oldukçada is slow. In short, easy to use, but a method of performance is very bad. JQuery in my project a long time and I never had even the slightest problem. JQuery in my master page I would add everything I want in the project and all I can do easily. If the plug-in for different situations has a lot. AutoComplete in one of these. Extension of the page can be found here, you can see demo here. In the example we will be told to search the database directly. Without further ado let’s look at the code again.
First download the necessary files, add to our project.
http://jquery.bassistance.de/autocomplete/jquery.autocomplete.js
http://jquery.bassistance.de/autocomplete/jquery.autocomplete.css
We then write our code
Page Default.aspx
<script type="text/javascript">
$(document).ready(function() {
$("input#<%=txtKelime.ClientID %>").autocomplete('Search.aspx').result(function(event, item) {
$("#<%=txtGizliAlan.ClientID %>").val(item.toString().split(",")[1]);
});
});
</script>
<form runat="server" id="form1">
<asp:textbox id="txtKelime" runat="server">
<asp:textbox id="txtGizliAlan" runat="server" style="display:none">
</asp:textbox></asp:textbox></form>
As we have seen in the above code txtGizliAlan area, we chose to store the record id of the value of our area. So here are going to write about the record id to the URL database are used. Our Search.aspx page
Page Default.aspx.cs
protected void page_load(object sender, EventArgs e) {
string strKelime = Request.QueryString["q"];// burada gelen değeri sql enjeksiyondan korunmak için kontrol etmeyi unutmayın !
DataTable dt = veritabani.DataTableGetir("Select * from tabloAdi where aranacakAlan like '%" + strKelime + "%'");
foreach (DataRow dr in dt.Rows)
{
Response.Write(dr["alanAdi"].ToString() + "|" + dr["id"].ToString() + Environment.NewLine);
}
}
It’s that easy! Neither do we have now an Autocomplete.
Tagged with: Asp.Net • autocomplete • plugin • search




[...] PostsSelected for actionUsing Autocomplete with Asp.NetDrag and drop sorting processWhy jQuery in asp.net?Cloud Zoom, Excellent work !Visual studio jQuery [...]