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:
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>
<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>
</div>
</form>
</body>
</html> |
la page AutoCompletion.asmx
Code:
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
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;
}
}