Wednesday, March 28, 2012

Why My AutocompleteExtender doesnt work Im gone crazy!!

Hi All!!!

I'm looking for help. I read lot of post in this forum but my AutocompleteExtender still not work. Can somebody help please!

this is my code behind of my Webservice

1using System;2using System.Data.SqlClient;3using System.Web;4using System.Collections;5using System.Collections.Generic;6using System.Web.Services;7using System.Web.Services.Protocols;8910/// <summary>11///12/// </summary>13[System.Web.Script.Services.ScriptService]14[WebService(Namespace ="http://tempuri.org")]15[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]16public class AutocompleteList : System.Web.Services.WebService {1718 public AutocompleteList () {1920//Uncomment the following line if using designed components21 //InitializeComponent();22 }2324 [WebMethod]25 [System.Web.Script.Services.ScriptMethod]26 public string[] GetList(string prefixe, int count)27 {28 List<string> art = new List<string>();29 string cnx = global::System.Configuration.ConfigurationManager.ConnectionStrings["artistesSQLServices"].ConnectionString;30 string select = "SELECT DISTINCT nom FROM [Table] WHERE nom LIKE @dotnet.itags.org.VALUE";31 SQLServer server = new SQLServer(cnx);32 if (server.Connect.State == System.Data.ConnectionState.Open)33 {34 SqlDataReader reader = null;35 SqlCommand cmd = new SqlCommand(select, server.Connect);36 cmd.Parameters.Add(new SqlParameter("@dotnet.itags.org.VALUE","%" + prefixe + "%"));37try38 {39 reader = cmd.ExecuteReader();40 cmd.Parameters.Clear();41 }42catch (Exception ex)43 {44string mess = ex.Message;45 }46finally47 {48if (reader.HasRows)49 {50while (reader.Read())51 {52 art.Add(reader.GetValue(0).ToString());53 }54 }55 reader.Close();56 reader.Dispose();57 cmd.Dispose();58 server.SQLDisconnect();59 }60 }61return art.ToArray();62 }63}

this is the code of my aspx page

<%

@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/users/Site.master"AutoEventWireup="true"

CodeFile

="Test.aspx.cs"Inherits="users_Test"Title="Untitled Page" %>

<%

@dotnet.itags.org.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:ScriptManagerID="ScriptManager1"runat="server"EnablePageMethods="true"EnablePartialRendering="true"></asp:ScriptManager><ajaxToolkit:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"TargetControlID="TextBox2"ServiceMethod="GetList"ServicePath="../AutocompleteList"CompletionInterval="10"CompletionSetCount="10"MinimumPrefixLength="3"Enabled="true"EnableCaching="true"></ajaxToolkit:AutoCompleteExtender> <asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>

</

asp:Content>

Hi,

Change your First Parameter "string prefixe" to be "string prefixText" . The Parameters are hard-coded in the WebService Invocation.

Check this Thread ..http://forums.asp.net/1598039/ShowThread.aspx#1598039


thanks for your help phanatic it works very well ............ BUT in debug mode only

when i call my page by this url :http://mymachine/mypage.aspx the autocompletion doesn't work. Do you know why?


ok,

we are making progressSmile

I see that you are calling an ASPX Page , are you trying to use the PageMethods ?

If you are , Please checkhttp://forums.asp.net/thread/1205564.aspx

If it resolves your issue , please mark my reply as the answer


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender, and 2 others files (Autocomplete.asmx and Autocomplet.cs) which contains the code of my webservice


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender and the two files of my webservice the "Autocomplet.asmx" and the code-behind "Autocomplete.cs"


hi,

Please drop me a sample at Phani_Rajyn@.yahoo.co.in


i've just sent you a sample

Hi ,

The sample contains SQLDataSource Connections and a lot of dependencies .

I cannot run this on my machine

can you please send me a self-contained sample that can run anywhere ?


hi phana

i've done some test with an other code in my webservice like this

1[WebMethod]2 [System.Web.Script.Services.ScriptMethod]3public string[] GetCompletionList(string prefixText,int count)4 {5int i = 0;6int iLength = 10;7 List Values =new List<string>();8for (i = 0; (i < iLength); i++)9 {10 Values.Add(Convert.ToString(prefixText + i.ToString()));11 }12 String[] strReturn =new String[Values.Count];13 strReturn = Values.ToArray();14return (strReturn);15 }

this code work very fine in debug mode and in normal mode. In my code i'm connecting to a SQLSERVER 2005 in an other machine.


I've done a test

I code a new page aspx just with the textbox an the autocompleteextender

i try my webservice it works fine. but when i add my website in IIS the autocompletextender doesn't work. it seems to be an issue in my IIS settings con you tell me what are the settings for IIS please


Hi,

"this code work very fine in debug mode and in normal "

If the code above works , then there are no issues with the AutoCompleteExtender , you should investigate the calls to the SQL Server you are making to understand what the issue is .

As far as IIS is concerned, are you gettting any errors related to IIS configuration ?


i find the issue it seems that IIS don't use my authentification to connect to the sqlserver

i've change my connection string and use the "sa" id user and password to connect

thx a lot for your help phana


just an other question can tell me how can i do a drag n drop from a textbox to an other textbox?

Hi,

great to know that we resolved the issue.

Can you please mark my reply as the answer ?

No comments:

Post a Comment