当'*'字符存在时禁用AutoCompleteExtender

时间:2009-07-28 09:21:21

标签: asp.net ajaxcontroltoolkit

我有一个问题。

我正在为我的文本框使用AutoCompleteExtender。所有自动填充单词显示。但是我需要下一个行为:当文本框中有'*'字符时,不得显示自动填充单词。

我该怎么做?

2 个答案:

答案 0 :(得分:5)

在ServiceMethod中,您可以检查字符串是否存在通配符,而不是返回任何结果?

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count) {
  string[] results = null;
  if (string.IndexOf("*") == -1) {
    // Retrieve your autocomplete options here.
    // Create a new string[] and add the options.
  }
  return results
}

答案 1 :(得分:0)

设置DelimiterCharacters =“*”

<cc1:AutoCompleteExtender OnClientItemSelected="ace1_itemSelected" EnableCaching="true"
                                    DelimiterCharacters="*" EnableViewState="false" Enabled="true" UseContextKey="true"
                                    ServicePath="PurchaseOrderDetails.aspx" ServiceMethod="GetItemTypes" MinimumPrefixLength="1"
                                    CompletionInterval="100" CompletionListCssClass="AutoCompleteExtender_CompletionList"
                                    CompletionListHighlightedItemCssClass="AutoCompleteExtender_HighlightedItem"
                                    CompletionListItemCssClass="AutoCompleteExtender_CompletionListItem" CompletionSetCount="5"
                                    TargetControlID="txtItemTypeCode" ID="aceItemTypeCode" runat="server">
                                </cc1:AutoCompleteExtender>