Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6799937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:54:30+00:00 2026-05-26T18:54:30+00:00

In Ajax, i am using autocompleteExender in my asp.net application, i write the service

  • 0

In Ajax, i am using autocompleteExender in my asp.net application, i write the service for that, when i run that service it is working fine, when i place autocompleteextender in asp.net page and assign properity for ajax autocompleteextender it is not working. this is my code service:

[WebMethod]
public string[] GetCompletionList(string prefixText)
{
    SqlConnection con=new SqlConnection
     ("server=******;database=Mydb;user id=***;password=****;");
    string sql = "Select productname from F_Product
      Where productname like '" + prefixText + "%'";
    SqlDataAdapter da = new SqlDataAdapter(sql, con); 
     try
    {
        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[0].ToString(), i);
            i++;
        }
        return items; 
    }
    catch
    {
        return null;
    }
    finally
    {
        con.Close();

    }

and this is my ajax autocompleteextender code.

<asp:AutoCompleteExtender ID="AutoCompleteExtender1" MinimumPrefixLength="2"
     TargetControlID ="TextBox1" ServiceMethod="GetCompletionList"
       ServicePath="~/Autocomplete.asmx"
         runat="server">
    </asp:AutoCompleteExtender> 
    <asp:TextBox ID="TextBox1" runat="server"
     Width="213px"></asp:TextBox>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:54:31+00:00Added an answer on May 26, 2026 at 6:54 pm

    Try this out.

    [WebMethod]
        public string[] GetCompletionList(string prefixText)
        {
    
            string sql = "Select productname from F_Product Where productname like @prefixText ";
            SqlDataAdapter da = new SqlDataAdapter(sql, System.Configuration.ConfigurationManager.ConnectionStrings["dbConnectionString"].ConnectionString);
            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["productname"].ToString(), i);
                i++;
            }
            return items;
        }
    

    If you find it useful, please mark it as your answer else let me know…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the MS AJAX AutoCompleteExtender on a textbox. It's working fine, except when
Using this tutorial: http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx The web service is invoked such as Service1.asmx/HelloToYou The default
I tried implementing a simple web service into an asp.net application using the tutorial
i had use Ajax using jquery. Now i had one page and in that
I seem to recall being able to configure asp.net ajax using attributes on the
I am working on ajax using struts 2 frame work. Application has two text
I'm using the AutoCompleteExtender from the AJAX control toolkit on my aspx page -
i m using asp.net mvc2 and i m submitting a form through ajax using
I am using jQuery to load a page by AJAX using $.ajax (suppose test.html).
I'm using AJAX.Net (3.5) inside a usercontrol. The usercontrol contains an UpdatePanel, and inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.