dear all ..

default.aspx

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<!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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <cc1:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" 
            DelimiterCharacters="1" MinimumPrefixLength="1" Enabled="True" ServiceMethod="GetProducts" ServicePath="WebService.asmx" TargetControlID="TextBox1">
        </cc1:AutoCompleteExtender>

    </div>
    </form>
</body>
</html>

webservice.cs

using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Data;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

    public WebService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string[] GetProducts(string prefixText)
    {
        string sql = "Select * from name Where name like @prefixText";
        SqlDataAdapter da = new SqlDataAdapter(sql, ConfigurationManager.AppSettings["sebBILL"]);
        da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%";
        DataTable dt = new DataTable();
        da.Fill(dt);
        string[] items = new string[dt.Rows.Count];
        int i = 0;
        foreach (DataRow dr in dt.Rows)
        {
            items.SetValue(dr["name"].ToString(), i);
            i++;
        }
        return items;
    }

}

this code not working properly..

any one please correct the code , i want add any code webconfig file ..

thank u

Recommended Answers

All 3 Replies

Hi there

what is not working "properly"?
let us know your exact problem, webservice or it is not showing on the webpage
Q1) : debug you webservice

Q2) : Uncomment // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]

Mark as solved if it helps you!!!

i don't have any error.. but not showing output in webpage textbox.. any code i want add ....

Hi there

what is not working "properly"?
let us know your exact problem, webservice or it is not showing on the webpage
Q1) : debug you webservice

Q2) : Uncomment // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]

Mark as solved if it helps you!!!

Hi satish

I already told you to uncomment the following line in my previous post

[System.Web.Script.Services.ScriptService]

mark as solved if it helps you!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.