Click here to Skip to main content
12,950,268 members (78,077 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hello sir/mam,

I am using for web application and I want to make a autosuggest box in which I input data and match with database table and show the list below the textbox on the web page, but it shows an error.

my html code is :
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<title>AutoComplete Textbox with webservice using jQuery</title>
<link href="" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(document).ready(function() {
function SearchText() {
source: function(request, response) {
type: "POST",
contentType: "application/json; charset=utf-8",
url: "webservice.asmx/GetAutoCompleteData",
data: "{'empname':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function(data) {
error: function(result) {
<form id="form1" runat="server">
<div class="demo">
<div class="ui-widget">
<label for="tbAuto">empname: </label>
<input type="text" id="txtSearch" class="autosuggest" />

and my webservice.asmx code is :
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data.SqlClient
Imports System.Collections.Generic
<WebService([Namespace]:="")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
Public Class AutoCompleteService
    Inherits System.Web.Services.WebService
    <WebMethod()> _
    Public Function GetAutoCompleteData(ByVal empname As String) As List(Of String)
        Dim result As New List(Of String)()
        Using con As New SqlConnection("Data Source=.;Initial Catalog=appraisal;User ID=sa;Password=database")
            Using cmd As New SqlCommand("select DISTINCT empname from EmpMst where empname LIKE '%'+@SearchText+'%'", con)
                cmd.Parameters.AddWithValue("@SearchText", empname)
                Dim dr As SqlDataReader = cmd.ExecuteReader()
                While dr.Read()
                End While
                Return result
            End Using
        End Using
    End Function
End Class

I donot know where to write this code whether on it webservice.asmx page or default.aspx.vb page
When I run this code, then it displays a alert box(error from the html page).
Posted 22-Feb-13 17:06pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,829
CHill60 3,460
Maciej Los 2,953
Jochen Arndt 1,975
ppolymorphe 1,820

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100