Some days before i was a problem i want to use autocomplete textbox with ajax. I found it from following link below
Ajax.NET comes without any web control, it is designed only for data exchange with the web server.
Here you will see how easy it is to implement a AutoComplete feature.
http://munich.schwarz-interactive.de/autocomplete.aspx
then i integrate it with in my system with some changes
Default.aspx
<p>
Customer:
<input type="text" id="searchCustomerID" /></p>
<script type="text/javascript" src="scripts/autocomplete.js"></script>
<script type="text/javascript">
function init() {
var x = new MS.Web.AutoCompleteDataTable("searchCustomerID", 10);
x.getDisplay = function(item) {
return (item != null ? item.CustomerName : "");
}
x.getValue = function(item) {
// return item.CustomerID;
return (item != null ? item.CustomerName.toString().trimRight() : "");
}
x.getData = function() {AutoComplete.Search(this.ele.value, this.count, this.callback.bind(this));
}
}
setTimeout(init, 1);
</script>
Default.aspx.vb
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AjaxPro.Utility.RegisterTypeForAjax(GetType(AutoCompleteWebForm))
End Sub
End Class
<AjaxPro.AjaxNamespace("AutoComplete")> _
Partial Public Class AutoCompleteWebFormInherits System.Web.UI.Page
<AjaxPro.AjaxMethod()> _
Public Function SimpleSearch(ByVal search As String) As String()
Return New String() {"AAA", "BBB", "CCC", search}
End Function
<AjaxPro.AjaxMethod()> _
Public Function Search(ByVal searchstr As String, ByVal count As Integer) As DataTable
Dim dt As New DataTable()dt.Columns.Add(
"CustomerID", GetType(Integer)) dt.Columns.Add("CustomerName", GetType(String))
Try
Try
Dim row As DataRow
row = dt.NewRow()
row("CustomerID") = "1"
row("CustomerName") = "2"
dt.Rows.Add(row)
row = dt.NewRow()
row("CustomerID") = "1"
row("CustomerName") = "3"
dt.Rows.Add(row)
Finally
End Try
Catch ex As Exception Throw ex
End Try
Return dt End Function
End Class