限制asp.net C中自动填充文本框中的项目数量#

时间:2022-04-29 05:34:31

I have added auto complete textbox like below lines of code

我添加了自动完整文本框,如下面的代码行

  <asp:TextBox ID="txtName" runat="server" onblur="NameChecker(this.value)" autocomplete="off" TabIndex="0"></asp:TextBox>
  <Ajax:AutoCompleteExtender ID="AutoCompleteExtender11" runat="server" TargetControlID="txtName"
                 MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="10" CompletionInterval="1000" ServiceMethod="GetNames" >
              </Ajax:AutoCompleteExtender> 


    [System.Web.Script.Services.ScriptMethod()]
    [System.Web.Services.WebMethod]
    public static List<string> GetNames(string prefixText)
    {
    OrganisationManger OrgManager = new OrganisationManger();
    Table<Organisation> ResultSet = OrgManager.GetOrganisationWithSameName(prefixText);
    List<string> Names = new List<string>();
    foreach (Organisation Organisation in ResultSet)
    {
        Names.Add(Organisation.Name.ToString());
    }   

    return Names;
}

Now I want to display only ten items in autocomplete dropdown. The above code is not working!!!

现在我想在自动完成下拉菜单中只显示十个项目。上面的代码不能正常工作!

1 个解决方案

#1


0  

Use overload form for service method.

使用重载表单作为服务方法。

public static List<string> GetNames(string prefixText, int count)

The count parameter will have the value you set using CompletionSetCount. Use this count parameter to limit number of results you return. Extender won't limit the results internally.

count参数将具有您使用CompletionSetCount设置的值。使用此count参数可限制返回的结果数。扩展器不会在内部限制结果。

#1


0  

Use overload form for service method.

使用重载表单作为服务方法。

public static List<string> GetNames(string prefixText, int count)

The count parameter will have the value you set using CompletionSetCount. Use this count parameter to limit number of results you return. Extender won't limit the results internally.

count参数将具有您使用CompletionSetCount设置的值。使用此count参数可限制返回的结果数。扩展器不会在内部限制结果。