IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

Probleme avec Ajax Toolkit AutoCompleteExtender


Sujet :

ASP.NET

  1. #1
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2003
    Messages
    353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2003
    Messages : 353
    Points : 361
    Points
    361
    Par défaut Probleme avec Ajax Toolkit AutoCompleteExtender
    Bonjour,
    j'essaie d'utiliser l'autocompleteextender, mais je m'arrache les cheveux, je ne comprends pas ce qu'il ne fonctionne pas dans mon code, quelqu'un peut il m'aider ?


    la page complete.aspx

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    <%@ Page Language="VB" %>
     
    <%@ 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">
     
    <script runat="server">
     
    </script>
     
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            &nbsp; &nbsp;
            <asp:TextBox ID="texte" runat="server" />
            <cc1:AutoCompleteExtender id="AutoCompleteExtender1" runat="server" Enabled="True" ServicePath="AutoCompletion.asmx" ServiceMethod="GetAutoCompletion" MinimumPrefixLength="1" targetcontrolid="texte">
            </cc1:AutoCompleteExtender>
            &nbsp;
        </div>
        </form>
    </body>
    </html>
    la page AutoCompletion.asmx
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    <%@ WebService Language="VB" Class="AutoCompletion" %>
     
    Imports System.Web
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
     
    <WebService(Namespace:="http://microsoft.com/webservices/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    Public Class AutoCompletion
        Inherits System.Web.Services.WebService
     
        <WebMethod()> _
        Public Shared Function GetAutoCompletion(ByVal prefixText, ByVal count) As String()
     
            Dim valeurs(10) As String
            Dim listeFinal As String = String.Empty
            Dim result(10000) As String
     
            valeurs(0) = "Gaetan"
            valeurs(1) = "Filipe"
            valeurs(2) = "Nicko"
            valeurs(3) = "Yann"
            valeurs(4) = "Fabrice"
            valeurs(5) = "Fallout"
            valeurs(6) = "Frimeur"
            valeurs(7) = "Fafrjb"
     
            For Each valeur As String In valeurs
                If valeur.StartsWith(prefixText, StringComparison.OrdinalIgnoreCase) Then
                    listeFinal += valeur & ";"
                End If
            Next
     
            result = listeFinal.Split(";")
            Array.Sort(result)
            GetAutoCompletion = result
     
        End Function
     
    End Class
    Le code est tout simple, mais impossible de le faire fonctionner.
    Merci par avance

  2. #2
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Points : 19 434
    Points
    19 434
    Par défaut
    Pkoi cela ne fonctionne-t-il pas ? Tu obtiens une erreur ?

    En déuggant le Web Service, tu vois quelque chose de particulier ?

  3. #3
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2003
    Messages
    353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2003
    Messages : 353
    Points : 361
    Points
    361
    Par défaut
    Bonjour Thomas,
    tout d'abord, merci de ta réponse.

    Je suis désolé, je n'ai pas précisé ce qu'il se passe.

    Lors de la compilation du fichier complete.aspx, je n'ai aucun message d'erreur.
    Je tape alors dans la textbox mais rien n'apparait.

    Si je compile le web service, il ne me semble pas qu'il y ait d'erreur.
    Je ne sais pas interprété la page qui s'ouvre mais rien ne semble indiquer une erreur.

    Je ne sais pas ou se trouve mon erreur.

  4. #4
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Points : 19 434
    Points
    19 434
    Par défaut
    Dans ton Web Service, a la place de
    GetAutoCompletion = result



    Essaye:
    Return result


    Car là, tu ne renvoie jamais le tableau donc il ne peut pas savoir quoi afficher....


    Cf: http://codingatlas.wordpress.com/200...g-large-lists/

  5. #5
    Membre habitué Avatar de davestar
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Septembre 2003
    Messages
    99
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2003
    Messages : 99
    Points : 125
    Points
    125
    Par défaut
    Bonjour
    je sais qu'en C# on doit rajouter ce TAG au dessus du webservice
    sinon ça ne marche pas
    [System.Web.Script.Services.ScriptService]

    donc je suppose que tu dois faire la même en VB
    <System.Web.Script.Services.ScriptService>
    --
    Cordialement
    David Verriere
    Mes articles techniques

  6. #6
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2003
    Messages
    353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2003
    Messages : 353
    Points : 361
    Points
    361
    Par défaut
    Bonjour,
    j'ai fait comme tu m'as dit, mais cela ne fonctionne toujours pas.

    Je n'arrive pas a comprendre, j'ai regardé sur le net.
    Je semble faire comme on le doit mais cela ne fonctionne pas.

    Y a t'il à faire quelque chose dans la configuration ?

  7. #7
    Membre habitué Avatar de davestar
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Septembre 2003
    Messages
    99
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2003
    Messages : 99
    Points : 125
    Points
    125
    Par défaut
    Rien de plus a mettre dans le web.config que celui fournit en reference avec Ajax.net
    --
    Cordialement
    David Verriere
    Mes articles techniques

  8. #8
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2003
    Messages
    353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2003
    Messages : 353
    Points : 361
    Points
    361
    Par défaut
    Merci pour ton aide,
    malheuresement, cela ne fonctionne pas.

    Cela fonctionne chez vous avec mon code ?

  9. #9
    Membre habitué Avatar de davestar
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Septembre 2003
    Messages
    99
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2003
    Messages : 99
    Points : 125
    Points
    125
    Par défaut
    Tu n'as pas appliqué le conseil de morpheus ni le mien dans ton code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    <System.Web.Script.Services.ScriptService()> _
    <WebService(Namespace:="http://microsoft.com/webservices/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    Public Class AutoCompletion
        Inherits System.Web.Services.WebService
        
        <WebMethod()> _
        Public Shared Function GetAutoCompletion(ByVal prefixText, ByVal count) As String()
            
            Dim valeurs(10) As String
            Dim listeFinal As String
            Dim result(10000) As String
            Dim valeur As String
            
            listeFinal = ""
            
            valeurs(0) = "Gaetan"
            valeurs(1) = "Filipe"
            valeurs(2) = "Nicko"
            valeurs(3) = "Yann"
            valeurs(4) = "Fabrice"
            valeurs(5) = "Fallout"
            valeurs(6) = "Frimeur"
            valeurs(7) = "Fafrjb"
            
            For Each valeur In valeurs
                If Left(valeur, Len(prefixText)) = prefixText Then
                    listeFinal = listeFinal & valeur & ";"
                End If
            Next
            
            GetAutoCompletion = Split(listeFinal, ";")
            Return GetAutoCompletion 
        End Function
    --
    Cordialement
    David Verriere
    Mes articles techniques

  10. #10
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2003
    Messages
    353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2003
    Messages : 353
    Points : 361
    Points
    361
    Par défaut
    En fait, j'ai essayé avec les divers conseils, en vain.

    Voici une version à jour, avec vos conseils.

    J'ai peur d'avoir fait un truc anormal, mais je vois pas quoi ...

  11. #11
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Points : 19 434
    Points
    19 434
    Par défaut
    Je vais pas pouvoir testé car je n'ai pas Atlas mais j'ai regardé ton code et il semble correct pour ce que j'ai vu....

  12. #12
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2003
    Messages
    353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2003
    Messages : 353
    Points : 361
    Points
    361
    Par défaut
    J'ai réussi a faire fonctionner avec la dll, Microsoft.web.atlas.dll
    Mais ca ne fonctionne pas avec AjaxControlToolkit.dll, je ne sais pas pourquoi.

    Aussi, en utilisant le premier, forcément, je ne peux plus utliser le deuxieme, qui contient plus de controles.

    Quelle est la différence entre les deux ?

  13. #13
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    215
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2005
    Messages : 215
    Points : 71
    Points
    71
    Par défaut
    Idem

  14. #14
    Membre habitué Avatar de davestar
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Septembre 2003
    Messages
    99
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2003
    Messages : 99
    Points : 125
    Points
    125
    Par défaut
    La pluspart des problemes avec ce composant viennent d'un oubli de tag dans le webservice
    --
    Cordialement
    David Verriere
    Mes articles techniques

  15. #15
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    312
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 312
    Points : 411
    Points
    411
    Par défaut
    Bonjour, j'ai le meme problème aujourd'hui, alors je remonte le post .

    J'ai exactement le même souci que celui de la personne qui a posté à l'origine.

    Quelqu'un aurait t'il une idée ?

  16. #16
    Membre habitué Avatar de davestar
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Septembre 2003
    Messages
    99
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2003
    Messages : 99
    Points : 125
    Points
    125
    Par défaut
    Bonjour,
    poste ton code aspx + ton code asmx ca aidera
    --
    Cordialement
    David Verriere
    Mes articles techniques

  17. #17
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    312
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 312
    Points : 411
    Points
    411
    Par défaut
    Salut, en créant le projet avec le template AJAX tout fonctionne correctement.

    Merci pour votre aide

  18. #18
    Candidat au Club
    Inscrit en
    Février 2008
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 2
    Points : 2
    Points
    2
    Par défaut AjaxControlToolkit Autocomplete tutorial
    Standard ASPX project
    <asp:ScriptManager ID="TheScriptManager" runat="server">
    <Services>
    <asp:ServiceReference Path="~/AutoComplete.asmx" />
    </Services>
    </asp:ScriptManager>

    If you're into a DotNetNuke apps ( in the module)

    if (DotNetNuke.Framework.AJAX.IsInstalled())
    {
    DotNetNuke.Framework.AJAX.RegisterScriptManager();

    ScriptManager myDotNetNukeScriptManager = ScriptManager.GetCurrent(this.Page);

    ServiceReference myServiceReference = new ServiceReference();
    myServiceReference.Path = @"~/DesktopModules/ExperimentationModule/AutoComplete.asmx";
    myDotNetNukeScriptManager.Services.Add(myServiceReference);
    }


    in ASPX section (WebDesign)
    <div>

    <asp:TextBox ID="txtTest” runat="server"></asp:TextBox>
    <cc1:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="txtTest" ServicePath="AutoComplete.asmx" ServiceMethod="GetWordsList" MinimumPrefixLength="1" EnableCaching="true" />

    </div>

    ASMX with no separate code file..
    <%@ WebService Language="C#" Class="AutoComplete" %>
    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Configuration;

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService
    {
    [WebMethod]
    public string[] GetWordsList(string prefixText)
    {
    string[] words = new string[14];
    words.SetValue("BEACH",0);
    words.SetValue("BEAT",1);
    words.SetValue("BECAME",2);
    words.SetValue("BECAUSE",3);
    words.SetValue("BED",4);
    words.SetValue("BEDROOM",5);
    words.SetValue("BEEN",6);
    words.SetValue("BEFORE",7);
    words.SetValue("BEG",8);
    words.SetValue("BEGONIAS",9);
    words.SetValue("BEHIND",10);
    words.SetValue("BELIEVE",11);
    words.SetValue("BELONG",12);
    words.SetValue("BELONGS",13);
    return words;
    }
    }

Discussions similaires

  1. [AJAX] ajax ie et readyState
    Par manouxus dans le forum Général JavaScript
    Réponses: 0
    Dernier message: 11/06/2008, 16h05
  2. probleme avec ajax sous IE
    Par mathieu92 dans le forum ASP.NET
    Réponses: 8
    Dernier message: 22/06/2007, 14h02
  3. [AJAX] AJAX ou Firefox ?
    Par stela86 dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 13/04/2006, 11h32
  4. [AJAX] Utilisation ajax
    Par Benjiijneb dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 10/04/2006, 18h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo