We help IT Professionals succeed at work.
Get Started

VB AJAX Toolkit Autocomplete extenderwon't work

Softacid
Softacid asked
on
825 Views
Last Modified: 2012-05-08
Hello i'm beginner in  VB.Net i tried to use the AJAX Toolkit Autocomplete extender with Web service .
The webservice works in browser and return the good results .. the textbox not working ..
Here's the code:

Default.aspx:

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="default.aspx.vb" Inherits="_Default"  %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="~/WebService.asmx" />
        </Services>
    </asp:ScriptManager>
    <div>
        
    
        <asp:AutoCompleteExtender ID="AutoCompleteExtender1" ServicePath="~/WebService.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="1" TargetControlID="tbInsert" CompletionInterval="1000" CompletionSetCount="20" runat="server" EnableCaching="true">
        </asp:AutoCompleteExtender>
        <asp:TextBox ID="tbInsert" runat="server" ></asp:TextBox>
    </div>
    </form>
</body>
</html>

WebService.asmx:

<%@ WebService Language="VB" Class="autocomplete" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports System.Data.Common
Imports System.Collections.Generic


<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class autocomplete
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function GetCompletionList(ByVal prefixText As String) As String()

        Dim con As SqlConnection

        con = New SqlConnection(ConfigurationManager.ConnectionStrings("mesteriConnectionString").ConnectionString)

        Dim dr As SqlDataReader

        Dim cmd As SqlCommand

        cmd = New SqlCommand("SELECT meserie FROM categorii WHERE meserie Like '" & prefixText & "%' ", con)

        con.Open()

        dr = cmd.ExecuteReader()



        Dim items As New List(Of String)

        While (dr.Read())

            items.Add(dr("meserie"))

        End While

        con.Close()

        Return items.ToArray
       

    End Function


End Class

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE