autocompelete extender not firing while running project

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 15054 Views - Last Post: 06 June 2010 - 05:17 AM Rate Topic: ***** 1 Votes

#1 Guest_kooly*


Reputation:

autocompelete extender not firing while running project

Posted 25 May 2010 - 06:14 AM

hello peopl am new at these ajax thing but i had read enough about autocompelete extender

then i attached ajax toolkit to my vs2008 and it attached well

the problem is that i did every thing to make it work and it didnt

please guys if anyone can solve this problem make post and help

first i have the web service code in here

using System;
using System.Configuration;
using System.Data;
using System.D

ata.SqlClient;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Configuration;

/// <summary>
/// Summary description for WebService
/// </summary>
// [ScriptService]
[System.Web.Script.Services.ScriptService()]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class WebService : System.Web.Services.WebService
{
    public WebService()
    {
        //Uncomment the following line if using designed components
        //InitializeComponent();
    }
    [WebMethod]
    //[System.Web.Script.Services.ScriptService]
       public string[] GetCountriesList(string prefixText, int count)
    {
        DataSet dtst = new DataSet();

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

        string strSql = "SELECT student_name FROM student  WHERE student_name 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 i = 0;

        try
        {

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

                cntName.SetValue(rdr["student_name"].ToString(), i);

                i++;

            }

        }

        catch { }

        finally
        {

            sqlCon.Close();

        }

        return cntName;

    }

}



then the asp default page
<%@ 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">
    

    <asp:ScriptManager ID="ScriptManager1" runat="server">
                <Services>

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

            </Services>

    </asp:ScriptManager>
    <asp:TextBox ID="TextBox1" runat="server" Height="22px" Width="536px"></asp:TextBox>
  
    <div>
    
        <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" 
                      ServiceMethod="GetCountriesList" 
            ServicePath="WebService.asmx" TargetControlID="TextBox1" UseContextKey="False" MinimumPrefixLength="1">
        </cc1:AutoCompleteExtender>
    
    </div>
   
    </form>
</body>
</html>




and here is my project link with db so u can try it in your pcs
http://www.mediafire.com/?3wmyyghnjmy
nothing happen after all this code :(

Is This A Good Question/Topic? 0

Replies To: autocompelete extender not firing while running project

#2 Guest_kooly*


Reputation:

Re: autocompelete extender not firing while running project

Posted 26 May 2010 - 01:56 PM

guys i really need to operate this property cause am counting on it to improving my college project to make it better and more usable

help
Was This Post Helpful? 0

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: autocompelete extender not firing while running project

Posted 26 May 2010 - 04:54 PM

The ScriptManager ServiceReference path needs to match the ServicePath in the AutoCompleteExtender.

Change this:
<asp:ServiceReference Path="AWebService.asmx" />

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

Was This Post Helpful? 1
  • +
  • -

#4 Guest_kooly*


Reputation:

Re: autocompelete extender not firing while running project

Posted 27 May 2010 - 06:26 AM

MR jayman i changed it and nothing happen
what can i do i have spent two weak trying do this property
cause i have to provide my project with it
can u help me please
Was This Post Helpful? 0

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: autocompelete extender not firing while running project

Posted 27 May 2010 - 06:48 AM

Unfortunately, I don't have WinRAR, so I can't unzip your project and determine the issue myself.

Any chance you can create a ZIP file of your project?

Is your web service running on the local machine?

Have you verified that the web service is working correctly and returning data?
Was This Post Helpful? 1
  • +
  • -

#6 Guest_kooly*


Reputation:

Re: autocompelete extender not firing while running project

Posted 27 May 2010 - 11:02 AM

FIRST OF ALL I UPLOAD it in zip file here it is
http://www.mediafire.com/?bmmzdmmzwen
and yes am putting my db in local host cause i will use it for my university grduation project


and i dont know how to trace the function and the break points issues

and am sorry for bothering u with my own problems^^
Was This Post Helpful? 1

#7 Guest_kooly*


Reputation:

Re: autocompelete extender not firing while running project

Posted 28 May 2010 - 08:24 AM

did it work mrr jayman??
Was This Post Helpful? 1

#8 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: autocompelete extender not firing while running project

Posted 28 May 2010 - 02:22 PM

Yes, I got your project. I'm still working on determining the issue.

It should be noted that the project you provided does not match what you posted above. You also didn't include the WebService in the zip file, so I am having to recreate parts of your project.
Was This Post Helpful? 1
  • +
  • -

#9 Guest_kooly*


Reputation:

Re: autocompelete extender not firing while running project

Posted 28 May 2010 - 02:32 PM

ops actually am sorry i send u the way i learn it from you tube which there is no web service in there the code written in the default1.aspx
but i tried the projects with web service and made like they had been explained but nothing firing *-*
Was This Post Helpful? 0

#10 koooly  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 29-May 10

Re: autocompelete extender not firing while running project

Posted 01 June 2010 - 07:19 AM

mr jayman
i have to deliver my whole project next saturday
and the autocompelet proberty is the last issue in my project
if u could find the problem befor saturday it will be so nice
thanks for help
Was This Post Helpful? 0
  • +
  • -

#11 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: autocompelete extender not firing while running project

Posted 01 June 2010 - 08:55 PM

I'm starting to think the issue is with the project you created.

I recreated the web service and started a new Ajax Control Toolkit Website with the following source.

Notice the ServicePath in the AutoCompleteExtender. It needs to be the complete path to your web service.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
        <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <ajaxToolkit:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" 
                runat="server" Enabled="True" MinimumPrefixLength="1" EnableCaching="true"
                ServiceMethod="GetCountriesList" ServicePath="http://localhost/WebService/WebService.asmx" TargetControlID="TextBox1" 
                UseContextKey="False">
            </ajaxToolkit:AutoCompleteExtender>
        </div>
    </form>
</body>
</html>


Using the following web service.
using System;
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.Data;
using System.Configuration;

[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[] GetCountriesList(string prefixText, int count)
    {
        DataSet dtst = new DataSet();

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

        string strSql = "SELECT student_name FROM student  WHERE student_name 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 i = 0;

        try
        {

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

                cntName.SetValue(rdr["student_name"].ToString(), i);

                i++;

            }

        }

        catch { }

        finally
        {

            sqlCon.Close();

        }

        return cntName;

    }

}



Once I recreated the website it worked just fine, however I could not establish why yours isn't working as expected.

You might try verify your web service matches mine and confirm it is working correctly, as well. Run your web service and click the GetCountriesList link. Supply a letter and a count of 1 and click the invoke button.

You should get some XML back reflecting the suggestions from your database based on the first letter. If this works, then move on to your web site.

Try creating a new project and adding the textbox and autocompleteextender. Run the project. Once you type a letter, give it a second to pop up the suggestion. I noticed it doesn't always react very fast when typing. See if that doesn't solve the issue.
Was This Post Helpful? 1
  • +
  • -

#12 koooly  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 29-May 10

Re: autocompelete extender not firing while running project

Posted 02 June 2010 - 04:48 AM

hey mr jay
i make the code as u do but it didnt work at all
maybe because of my ajax you prefix ajaxtoolkit but look at min it is asp and cc1

look at the code of mine down there is it problem if it begins with asp or cc1
<body> 
    <form id="form1" runat="server"> 
      <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        <div> 
        <asp:TextBox ID="TextBox1" runat="server"  ></asp:TextBox> 
       
           
            <cc1:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender"   runat="server" Enabled="True" MinimumPrefixLength="1" EnableCaching="true" 
                ServiceMethod="GetCountriesList" ServicePath="http://localhost/WebService/WebService.asmx" TargetControlID="TextBox1"  
                UseContextKey="False">
            </cc1:AutoCompleteExtender>
          
       
           
        </div> 
    </form> 
</body> 


Was This Post Helpful? 0
  • +
  • -

#13 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: autocompelete extender not firing while running project

Posted 02 June 2010 - 10:26 AM

Since you are doing this in VS2008 you don't need to register the DLL. Make sure you create an Ajax Control Toolkit Website project, it will register the AjaxControlToolkit for you.

If you don't see that type of template installed when you try to create a new project, then you can download it here.

Are you targeting the 2.0 or 3.5 .NET Framework in your project?
Was This Post Helpful? 1
  • +
  • -

#14 koooly  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 29-May 10

Re: autocompelete extender not firing while running project

Posted 02 June 2010 - 11:46 AM

i use 3.5
but to be honest i start doubting in my vs caus i downloaded a source codes from internet and change the path and select into mine db
and still nothing

is there chance that some tools of ajax works and others not cause i use calender ajax and masked tool and it works

the auto compelete when i drag it it doesnt stick any where just only inside textbox
look down this pics
http://store1.up-00....10/Sve04233.jpg
http://store1.up-00....10/nMb04233.jpg

if u could give the source code that u run and worked with then i try

This post has been edited by koooly: 02 June 2010 - 11:49 AM

Was This Post Helpful? 0
  • +
  • -

#15 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: autocompelete extender not firing while running project

Posted 02 June 2010 - 06:24 PM

Alright. Here is the example that I setup.

I didn't include the database since you already have one.

Don't forget to change the database connection string in the web.config of the web service to connect to your database.

Attached File  AutoCompleteExtender Example.zip (305.56K)
Number of downloads: 197

As you can see it is working.

Attached Image
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2