Pourquoi mon autocomplete script ajax ne fonctionne pas:auto complète asp.net
Ceci est mon WebService.cs:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Configuration;
using System.Web.Script.Services;
[ScriptService]
[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.
public class WebService : System.Web.Services.WebService {
public WebService() {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string[] GetCountryInfo(string prefixText, int count)
{
string sql = "Select * from questions Where username like @prefixText";
SqlDataAdapter da = new SqlDataAdapter(sql,"estudent_piooConnectionString");
da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%";
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 1;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["username"].ToString(),i);
i++;
}
return items;
}
}
mon css:
/*AutoComplete flyout */
.autocomplete_completionListElement {
marge: 0px! Important; background-color: hériter; couleur: windowtext; bordure: buttonshadow; largeur de bordure: 1px; style bordure: solide; cursor: 'default'; dépassement de capacité: auto; hauteur: 200px; text-align: à gauche; type de style de liste: aucun; remplissage: 0px; }
/* * Saisie semi-automatique mis en évidence article/
.autocomplete_highlightedListItem { background-color: # FFFF99; couleur: noir; rembourrage: 1px; }
/* article * Saisie semi-automatique/
.autocomplete_listItem { background-color: fenêtre; couleur: windowtext; rembourrage: 1px; }
et zone de texte:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem" CompletionSetCount="20"
CompletionInterval="1000" DelimiterCharacters=";,:"
CompletionListHighlightedItemCssClass="autocomplete_highlightedList MinimumPrefixLength="1" ServiceMethod="GetCountryInfo" ShowOnlyCurrentWordInCompletionListItem="true" TargetControlID="TextBox2" ServicePath="WebService.asmx" runat="server"></cc1:AutoCompleteExtender>
Parce qu'il ya trop de questions sans réponse acceptée – Alex
Je ne get it .. je n'ai pas de champ "réponses" dans ma table "questions" ... –
Vous allez voir la question, alors vous sélectionnez "accepter la réponse" pour celui qui est correct. – egrunin