Thursday, May 19, 2011

AJAX AutoComplete Feature Implementation Example

1.       Add AJAXControltoolkit dll in your web site reference
2.       Drag n drop script manager on the top of the page (if already included inmaster page then no need)
3.     Place folowing html in your html page

<ajaxToolkit:AutoCompleteExtender ID="AutoCompletePeople" runat="server" TargetControlID="txtUsers " 
DelimiterCharacters=","  MinimumPrefixLength="1" ServicePath="NewQuestion.aspx"
ServiceMethod="GetUsersList" UseContextKey="True"
EnableCaching="true"
CompletionSetCount="5"
CompletionInterval="1000"
BehaviorID="autoCompleteBehavior1">


4.      Write following code in aspx.cs class file
#region AutoComplete Users
        //Specify this method as ServiceMethod for Company Completion List
        [System.Web.Services.WebMethod]
        public static string[] GetUsersList(string prefixText, int count)
        {
            string[] result = selectUsers(prefixText);// this method returns all the users
            return result;
        }
        #endregion  AutoComplete Users END

Here is the link for AJAX  Auto complete features  and more
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/AutoComplete/AutoComplete.aspx

No comments:

Post a Comment