-4
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetRowsByFilter(string prefixText, int count)
//public static List<string> GetRowsByFilter(string prefixText)
{
DataTable table = ds.Tables[0];
string filter = "stShortName LIKE '" + prefixText.Replace("'", "''") + "%'";
DataRow[] foundRows;
List<string> items = new List<string>(count);
foundRows = table.Select(filter);
if (foundRows.Length > 0)
{
for (int i = 0; i < foundRows.Length; i++)
{
items.Add((string)foundRows[i]["stShortName"]);
}
return items.ToArray();
}
else
{
items.Add("No '" + prefixText + "' items found");
return items.ToArray();
}
}
<ajaxToolkit:AutoCompleteExtender
id="AutoCompleteExtenderTxtSite"
BehaviorID="AutoCompleteEx"
Runat="server"
Targetcontrolid="txtSiteASP"
ServiceMethod="GetRowsByFilter"
MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="false"
CompletionSetCount="10"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true"
>
<Animations>
<OnShow>
<Sequence>
<OpacityAction Opacity="0" />
<HideAction Visible="true" />
<ScriptAction Script="
// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />
<Parallel Duration=".4">
<FadeIn />
<Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<Parallel Duration=".4">
<FadeOut />
<Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</ajaxToolkit:AutoCompleteExtender>
這其中大部分是直接從工具包樣品的網站。除了從數據庫中填充數組外,我也完全按照示例使用Web服務來完成它。兩個都完美無瑕地填充陣列,並且有時都起作用。缺乏表現力,他們似乎是相同的。
我在另一個頁面上使用了幾個日曆控件,他們的工作完美無瑕,但浪費太多時間試圖使這項工作始終如一。
什麼問題? – 2008-12-28 23:55:32