AutoCompleteExtender does not work - please help me

Last post 04-02-2009 4:29 AM by Vince Xu - MSFT. 3 replies.

Sort Posts:

  • AutoCompleteExtender does not work - please help me

    03-31-2009, 8:28 AM

    IN my project  when i Use  webservice it doesn't call from  UI  . autoextender not working properly  when I put my webservices.asmx  file in bin folder it giving error like

    HTTP Error 403 - Forbidden. 

    using System;

    using System.Web;

    using System.Collections;

    using System.Web.Services;

    using System.Web.Services.Protocols;

    using System.Data;

    using System.Data.SqlClient;

    using System.Configuration;

    using System.Collections.Generic;

     

     

    /// <summary>

    /// Summary description for WebService

    /// </summary>

    [WebService(Namespace = "http://tempuri.org/")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    [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[] autofiiltextbox(string prefixtext)

    {

    DataSet dtst = new DataSet();

    //SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["educationDevConnectionString"]);

    SqlConnection sqlCon = new SqlConnection("Data Source=10.131.2.190;Initial Catalog=educationDev;User ID=mp-group-a ;password=Gr#07@NicM;");

     

    string strSql = " select top(10) ois_code +'-'+ ois_name as check1 from Msr_OISs WHERE ois_name LIKE '" + prefixtext + "%' or OIS_Code LIKE '" + prefixtext + "%' ";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 i1 = 0;

    try

    {

    foreach (DataRow rdr in dtst.Tables[0].Rows)

    {

    cntName.SetValue(rdr[
    "check1"].ToString(), i1);

    i1++;

    }

    }

     

    catch { }

    finally

    {

    sqlCon.Close();

    }

    return cntName;

     

     

     

    }

     

     

    }

     

     

    <%@ 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.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

    <title>Consume Web Service</title>

    </head>

    <body>

    <form id="form1" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True" >

    <Services >

    <asp:ServiceReference Path ="WebService.asmx" />

     

    </Services>

    </asp:ScriptManager>

    <div>

    <asp:TextBox ID="txtcode" runat="server"></asp:TextBox>

    </div>

    <%-- <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID ="txtcode" ServicePath ="WebService.asmx" ServiceMethod = "autofiiltextbox" MinimumPrefixLength ="1" EnableCaching ="true">

    </cc1:AutoCompleteExtender>--%>

    <cc1:AutoCompleteExtender ID ="autocomlpte" runat ="server" TargetControlID ="txtcode" ServicePath="WebService.asmx" ServiceMethod="autofiiltextbox" MinimumPrefixLength="1" CompletionInterval ="1000" EnableCaching ="true" >

    </cc1:AutoCompleteExtender>

    </form>

    </body>

    </html>

     

    pls send me reply on digarse.rakesh@gmail.com

  • Re: AutoCompleteExtender does not work - please help me

    03-31-2009, 8:47 AM

    One issue is with this:

    public string[] autofiiltextbox(string prefixtext)

    It should use prefixText, case sensitive.  Also, I think that you have to specify a count parameter.  So you signature would be:

    public string[] autofiiltextbox(string prefixText, int count)

  • Re: AutoCompleteExtender does not work - please help me

    03-31-2009, 8:48 AM

    Hi,

    USE THE METHOD LIKE FOLLOWING AND YOU ARE DONE :

    public string[] autofiiltextbox(string prefixText, int count)

    Always "Mark as Answer" the Post That Solves the problem.Because It helps others to find the solution.
    Mohammad Hussain
    http://mohdhussain.blogspot.com/
  • Re: AutoCompleteExtender does not work - please help me

    04-02-2009, 4:29 AM
    Answer

    Hi,

    Firstly, please use 

    public string[] autofiiltextbox(string prefixText, int count) instead of your declaration. prefixText is not a reference name of method, it's the key of JSON which is transfered to the server-side. So we have to keep "prefixText" as the key name rather than others.

    And please make sure you define Class="AutoComplete" as the Class property for webservice.asmx file.

     


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)