Click here to Skip to main content
15,885,941 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: , +
Hi,
I am using asp.net 2008 and trying to use AutocompleteExtender in page
but its not working while when i m using calendar extender its working fine.

aspx code is
XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.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" EnablePartialRendering="true">
             <Services>
                <asp:ServiceReference Path="~/AutoComplete.asmx" />
             </Services>
        </asp:ScriptManager>
        <div>
            <asp:TextBox ID="txtCountry" runat="server"></asp:TextBox>
            <cc1:AutoCompleteExtender ID="txtCountry_AutoCompleteExtender" runat="server"
                ServicePath="AutoComplete.asmx" ServiceMethod="GetCountriesList" MinimumPrefixLength="1" EnableCaching="true" Enabled="true"
                TargetControlID="txtCountry">
            </cc1:AutoCompleteExtender>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <cc1:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
                Enabled="True" TargetControlID="TextBox1" PopupButtonID="TextBox1">
            </cc1:CalendarExtender>
        </div>
    </form>
</body>
</html>

and AutoComplete.asmx page code is:
C#
public string[] GetCountriesList(string prefixText)
    {
        DataSet dtst = new DataSet();
        SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);
        string strSql = "SELECT Fullname FROM owner.empmaster WHERE Fullname LIKE '" + prefixText + "%' and owner.empmaster.active=0 and owner.empmaster.status=0 ";
        SqlCommand sqlComd = new SqlCommand(strSql, sqlCon);
        sqlCon.Open();
        SqlDataAdapter sqlAdpt = new SqlDataAdapter();
        sqlAdpt.SelectCommand = sqlComd;
        sqlAdpt.Fill(dtst);
        string[] cntName = new string[dtst.Tables[0].Rows.Count];
        int i = 0;
        try
        {
            foreach (DataRow rdr in dtst.Tables[0].Rows)
            {
                cntName.SetValue(rdr["Fullname"].ToString(), i);
                i++;
            }
        }
        catch { }
        finally
        {
            sqlCon.Close();
        }
        return cntName;
    }

Thanks in advance..
Posted
Updated 1-Dec-10 19:36pm
v2
Comments
Sandeep Mewara 2-Dec-10 1:36am    
Use PRE tags to format code part from next time. It makes the question readable.
Dave Kreskowiak 2-Dec-10 7:55am    
Go back and define what you mean by "not working". What is it DOING and what are you EXPECTING it to do?

1 solution

please tell me why you are using AutoCompleteExtender while you can take same work by using ajaxtoolkit:Combobox1 ,while set its property to SuggestAppend.Reply.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900