Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. auto complete with ajaxcontroltoolkit and ado.net

auto complete with ajaxcontroltoolkit and ado.net

Scheduled Pinned Locked Moved ASP.NET
csharphelphtmllinqdesign
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Ya Rasoolallah
    wrote on last edited by
    #1

    hello to all i have a problem with the program that see in below; this program has not any syntax error but doesn't work; i thank you if help me.:rose: Default.aspx page:

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

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">

    </form>
    

    </body>
    </html>

    Default.aspx.cs

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.SqlClient;

    public partial class Default2 : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    

    }

    in .asmx file

    <%@ WebService Language="C#‎‎‎" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>

    in .asmx code behind file

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Linq;
    using System.Data.SqlClient;
    using System.Configuration;

    /// /// this WebService is designed for autocomplete with ajaxControlToolkit and ADO.Net
    ///
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to

    T J 2 Replies Last reply
    0
    • Y Ya Rasoolallah

      hello to all i have a problem with the program that see in below; this program has not any syntax error but doesn't work; i thank you if help me.:rose: Default.aspx page:

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

      <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

      <html xmlns="http://www.w3.org/1999/xhtml">
      <head runat="server">
      <title>Untitled Page</title>
      </head>
      <body>
      <form id="form1" runat="server">

      </form>
      

      </body>
      </html>

      Default.aspx.cs

      using System;
      using System.Collections;
      using System.Configuration;
      using System.Data;
      using System.Linq;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.HtmlControls;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Xml.Linq;
      using System.Data.SqlClient;

      public partial class Default2 : System.Web.UI.Page
      {
      protected void Page_Load(object sender, EventArgs e)
      {

      }
      

      }

      in .asmx file

      <%@ WebService Language="C#‎‎‎" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>

      in .asmx code behind file

      using System;
      using System.Collections;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.Services;
      using System.Web.Services.Protocols;
      using System.Xml.Linq;
      using System.Data.SqlClient;
      using System.Configuration;

      /// /// this WebService is designed for autocomplete with ajaxControlToolkit and ADO.Net
      ///
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      // To allow this Web Service to

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      For parameter fields you should add prefix @, like below

      Ya Rasoolallah wrote:

          string query = "select \* from tbl\_users where username like **@**username";
          SqlCommand cm = new SqlCommand(query,cn);
          cm.Parameters.AddWithValue("**@**username","N%"+prefixT  ext+"%");
      

      thatraja

      Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute

      Y 1 Reply Last reply
      0
      • T thatraja

        For parameter fields you should add prefix @, like below

        Ya Rasoolallah wrote:

            string query = "select \* from tbl\_users where username like **@**username";
            SqlCommand cm = new SqlCommand(query,cn);
            cm.Parameters.AddWithValue("**@**username","N%"+prefixT  ext+"%");
        

        thatraja

        Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute

        Y Offline
        Y Offline
        Ya Rasoolallah
        wrote on last edited by
        #3

        thanks:rose: my friend , still does not work. why? :(: test it please.

        T 1 Reply Last reply
        0
        • Y Ya Rasoolallah

          thanks:rose: my friend , still does not work. why? :(: test it please.

          T Offline
          T Offline
          thatraja
          wrote on last edited by
          #4

          I don't think you need N in below line

          cm.Parameters.AddWithValue("**@**username","N%"+prefixText+"%");

          Debug your code & make sure you get data in SqlDataReader dr(below line)

          while (dr.Read())

          Before that make sure you have data in your database table tbl_users. I think you tried example from this article[^] so make sure you didn't miss any steps mentioned there.

          thatraja

          Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute

          Y 1 Reply Last reply
          0
          • T thatraja

            I don't think you need N in below line

            cm.Parameters.AddWithValue("**@**username","N%"+prefixText+"%");

            Debug your code & make sure you get data in SqlDataReader dr(below line)

            while (dr.Read())

            Before that make sure you have data in your database table tbl_users. I think you tried example from this article[^] so make sure you didn't miss any steps mentioned there.

            thatraja

            Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute

            Y Offline
            Y Offline
            Ya Rasoolallah
            wrote on last edited by
            #5

            hello the problem is not from @ or N and etc... my program doesn't have any syntax error but doesn't work not at all. please debug my program to see why not to work?thanks.:rose::rose: i worked from that example link that you said step by step exactly.

            1 Reply Last reply
            0
            • Y Ya Rasoolallah

              hello to all i have a problem with the program that see in below; this program has not any syntax error but doesn't work; i thank you if help me.:rose: Default.aspx page:

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

              <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

              <html xmlns="http://www.w3.org/1999/xhtml">
              <head runat="server">
              <title>Untitled Page</title>
              </head>
              <body>
              <form id="form1" runat="server">

              </form>
              

              </body>
              </html>

              Default.aspx.cs

              using System;
              using System.Collections;
              using System.Configuration;
              using System.Data;
              using System.Linq;
              using System.Web;
              using System.Web.Security;
              using System.Web.UI;
              using System.Web.UI.HtmlControls;
              using System.Web.UI.WebControls;
              using System.Web.UI.WebControls.WebParts;
              using System.Xml.Linq;
              using System.Data.SqlClient;

              public partial class Default2 : System.Web.UI.Page
              {
              protected void Page_Load(object sender, EventArgs e)
              {

              }
              

              }

              in .asmx file

              <%@ WebService Language="C#‎‎‎" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>

              in .asmx code behind file

              using System;
              using System.Collections;
              using System.Collections.Generic;
              using System.Linq;
              using System.Web;
              using System.Web.Services;
              using System.Web.Services.Protocols;
              using System.Xml.Linq;
              using System.Data.SqlClient;
              using System.Configuration;

              /// /// this WebService is designed for autocomplete with ajaxControlToolkit and ADO.Net
              ///
              [WebService(Namespace = "http://tempuri.org/")]
              [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
              // To allow this Web Service to

              J Offline
              J Offline
              joginder banger
              wrote on last edited by
              #6

              I have used many time auto complete Extender. I check out your code behind file.

              [WebMethod]
              public static string[] City(string prefixText, int count, string contextKey)
              {

                  DataTable dt = new DataTable();
              
                  dt = Bal\_BindingData.\_city(prefixText);
              

              //_city is dataTable type function with the string type parameter.just add the String Contextkey in your GetCompletionList method.

                  string\[\] movies = new string\[dt.Rows.Count\];
                  for (int i = 0; i < dt.Rows.Count; i++)
                  {
                      movies\[i\] = dt.Rows\[i\]\["City"\].ToString();
              
                  }
              
              
                  return movies;
              }
              

              i think you forgot string Contextkey Parameter in GetCompletionList method. don't confused my with code i have used three tire technique. I hope your problem has been solved. :laugh: jsb

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups