2012-03-22 71 views
0

我試圖使用AJAX自動完成擴展,但它不工作.... 我把在Web服務的方法GetCompanyNames一個破發點,但它甚至沒有達到突破點。AJAX自動完成擴展不工作的權利,VB.Net

這裏是我的ajax autoextender

<asp:TextBox TabIndex="1" ToolTip="* Required - enter the Company name" ID="txtCompanyName" 
runat="server"></asp:TextBox> 
<ajaxToolkit:AutoCompleteExtender runat="server" ID="acCompanyName" TargetControlID="txtCompanyName" ServiceMethod="GetCompanyNames" ServicePath="~/WebServices/AutoComplete.asmx" MinimumPrefixLength="1" 
EnableCaching="true"> 
</ajaxToolkit:AutoCompleteExtender> 

這裏是我創建

Imports System.Web 
    Imports System.Web.Services 
    Imports System.Web.Services.Protocols 

    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    ' <System.Web.Script.Services.ScriptService()> _ 
    <WebService(Namespace:="http://tempuri.org/")> _ 
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ 
    <System.Web.Script.Services.ScriptService()> _ 
    Public Class AutoComplete 
     Inherits System.Web.Services.WebService 

<WebMethod()> _ 
Public Function HelloWorld() As String 
    Return "Hello World" 
End Function 

<WebMethod()> _ 
Public Function GetCompanyNames(ByVal prefixTest As String) As String() 

    Dim db As New DataClassesDataContext 

    Dim company = From c In db.CT_Companies 
        Where c.CompanyName.Contains(prefixTest) 
        Select c.CompanyName 

    Return company.ToArray 

End Function 

    End Class 

任何人都可以看到我在做什麼錯誤或丟失的網絡服務?謝謝

回答

0

根據文檔here,您在方法簽名中缺少<System.Web.Script.Services.ScriptMethod()>屬性和整數count參數。

+0

我嘗試添加這兩個的,仍然沒有工作..... – user1202606 2012-03-22 22:54:46