您好,登錄后才能下訂單哦!
DE:Visual Web Developer 2008 Express Edition
DB:Access 2007
到http://www.asp.net/ajax/downloads/下載AJAX Control Toolkit,將AjaxControlToolkit.dll拷貝到項目的bin目錄下,在工具欄中引入。
在Web.config的<controls>...</controls>里加上
[xhtml] view plain copy
< add tagPrefix = "ajaxToolkit" namespace = "AjaxControlToolkit" assembly = "AjaxControlToolkit" />
WebService的代碼:(aaa.asmx)
[vb] view plain copy
<WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
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" > </ asp:TextBox >
< ajaxToolkit:AutoCompleteExtender ID = "txtNo_AutoCompleteExtender" runat = "server" Enabled = "True" ServiceMethod = "GetCompletionList" ServicePath = "aaa.asmx" TargetControlID = "txtNo" MinimumPrefixLength = "1" EnableCaching = "true" >
</ ajaxToolkit:AutoCompleteExtender >
以上即可。
AJAX日期控件的使用也很方便,如:
[xhtml] view plain copy
< asp:TextBox ID = "txtDate" runat = "server" Columns = "24" > </ asp:TextBox >
< ajaxToolkit:CalendarExtender ID = "txtDate_CalendarExtender" runat = "server" Enabled = "True" TargetControlID = "txtDate" >
</ ajaxToolkit:CalendarExtender >
如果您覺得此篇文章對您有幫助,歡迎關注微信公眾號:大禹編程,您的支持是對我最大的鼓勵!共同學習,共同進步:)
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。