John
John

Reputation: 297

Improving speed AJAX AutoCompletion - ASP.NET C#

First problem is the list of what pops up is far below the actual textbox. See pic. pic

2nd problem is it takes a full second or two to get any results using auto completion. I doubt its database/retrieval related, because using a local string array of names, gives me the same results.

.aspx

            <asp:ScriptManager ID="ScriptManager1" runat="server">

            </asp:ScriptManager>

             <asp:TextBox ID="txtFrom" runat="server">
            </asp:TextBox>
            <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtFrom" MinimumPrefixLength="1" ServiceMethod="GetSuggestions" EnableCaching="true">
            </ajaxToolkit:AutoCompleteExtender>

My web method is in my cs class

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] GetSuggestions(string prefixText, int count)
{
    IList<String> donors = new List<String>();

    NHibernateSessionManager sessionManager = new NHibernateSessionManager();
    NHibernate.ISession session = sessionManager.GetSession();
    NHibernateDataProvider2 provider = new BT4SGWebApplication.NHibernateDataProvider2(session);

    ExtraUserInfo user = provider.CRIT_GetDistinctExtraUserInfoByUserName(System.Web.HttpContext.Current.User.Identity.Name)[0];

    return user.GroupTable.PayorDonors.Where(x => x.Name.FullName.StartsWith(prefixText)).OrderBy(x => x.Name.FullName)
    .Select<PayorDonor, string>(x => x.Name.FullName).ToArray();
}

PS - hit isn't my last name.

Upvotes: 0

Views: 1250

Answers (1)

StriplingWarrior
StriplingWarrior

Reputation: 156594

Try setting a low CompletionInterval on your AutoCompleteExtender. A big part of the delay you're running into is probably a result of this (1 second default) delay.

Upvotes: 1

Related Questions