DE:Visual Web Developer 2008 Express Edition
DB:Access 2007
到http://www.asp.net/ajax/downloads/下载AJAX Control Toolkit,将AjaxControlToolkit.dll拷贝到项目的bin目录下,在工具栏中引入。
在Web.config的...里加上
[xhtml] view plain copy
< add tagPrefix = "ajaxToolkit" namespace = "AjaxControlToolkit" assembly = "AjaxControlToolkit" />
WebService的代码:(aaa.asmx)
[vb] view plain copy
_
_
Public Function GetCompletionList( ByVal prefixText As String , ByVal count As Integer ) As String ()
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim dbname As String
dbname = Server.MapPath( "location.accdb" )
myConnection = New OleDbConnection( "Provider=Microsoft.ACE.OLEDB.12.0;DATA Source=" & dbname)
myConnection.Open()
Dim list As New List(Of String )
myCommand = New OleDbCommand( "SELECT DISTINCT(columnName) FROM tableName WHERE columnName LIKE '" + prefixText & "%" + "'" , myConnection)
Dim reader As OleDbDataReader = myCommand.ExecuteReader()
Do While reader.Read
list.Add(reader.GetString(0))
Loop
Return list.ToArray()
End Function
FORM中的代码:(aaa.aspx)
[xhtml] view plain copy
< asp:TextBox ID = "txtNo" runat = "server" autopostback = "true" Columns = "50" >
< ajaxToolkit:AutoCompleteExtender ID = "txtNo_AutoCompleteExtender" runat = "server" Enabled = "True" ServiceMethod = "GetCompletionList" ServicePath = "aaa.asmx" TargetControlID = "txtNo" MinimumPrefixLength = "1" EnableCaching = "true" >
以上即可。
AJAX日期控件的使用也很方便,如:
[xhtml] view plain copy
< asp:TextBox ID = "txtDate" runat = "server" Columns = "24" >
< ajaxToolkit:CalendarExtender ID = "txtDate_CalendarExtender" runat = "server" Enabled = "True" TargetControlID= "txtDate" >
如果您觉得此篇文章对您有帮助,欢迎关注微信公众号:大禹编程,您的支持是对我最大的鼓励!共同学习,共同进步:)
网友评论