这是代码:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods = "true"
AsyncPostBackTimeout="1000" ScriptMode="Release"
EnablePartialRendering="true" >
<Services>
<asp:ServiceReference Path ="~/FolderForService/Service.asmx" />
</Services>
<Scripts>
<asp:ScriptReference Path="~/jscript/common.js" />
</Scripts>
</asp:ScriptManager>
<asp:UpdatePanel ID="upFSK" runat ="server" UpdateMode ="Conditional" >
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" >
<asp:TextBox ID="TextBox1" runat="server" Visible="True" Width="128px"></asp:TextBox>
<cc1:AutoCompleteExtender ID="ACE"
runat="server"
ServicePath="~/FolderForService/Service.asmx"
ServiceMethod="WebMethod"
MinimumPrefixLength="4"
CompletionSetCount = "10"
TargetControlID="TextBox1">
</cc1:AutoCompleteExtender>
</Panel>
</ContentTemplate>
</UpdatePanel>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Linq
Imports System.Web.Caching
Imports System.Data
Imports System.Collections.Generic
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService
'Web method which doesn't fire
<WebMethod()> _
Public Shared Function WebMethod(ByVal prefixTekst As String, ByVal count As Integer) As List(Of String)
' Code
End Function
End Class
我做了什么:
我错过了什么?
答案 0 :(得分:0)
我只在c#中完成了这个,我可以给你一个c#例子如果你请求它,否则检查这个资源,它应该可以帮助你实现这个目的。 http://www.aspsnippets.com/Articles/ASP.Net-AJAX-Control-Toolkit-AutoCompleteExtender-without-using-Web-Services.aspx
从链接:
ASP:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods = "true">
</asp:ScriptManager>
<asp:TextBox ID="txtContactsSearch" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="SearchCustomers"
MinimumPrefixLength="2"
CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
TargetControlID="txtContactsSearch"
ID="AutoCompleteExtender1" runat="server" FirstRowSelected = "false">
</cc1:AutoCompleteExtender>
VB:
<System.Web.Script.Services.ScriptMethod(), _
System.Web.Services.WebMethod()> _
Public Shared Function SearchCustomers(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim conn As SqlConnection = New SqlConnection
conn.ConnectionString = ConfigurationManager _
.ConnectionStrings("constr").ConnectionString
Dim cmd As SqlCommand = New SqlCommand
cmd.CommandText = "select ContactName from Customers where" & _
" ContactName like @SearchText + '%'"
cmd.Parameters.AddWithValue("@SearchText", prefixText)
cmd.Connection = conn
conn.Open()
Dim customers As List(Of String) = New List(Of String)
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
customers.Add(sdr("ContactName").ToString)
End While
conn.Close()
Return customers
End Function
答案 1 :(得分:0)
设置你的页面属性EnableEventValidation =&#34; false&#34;。它会工作。