Friday, 24 May 2013

Example Of AutoCompleteExtender Control in ajax in asp.net


Introduction:-


                  in this example we explain that how to create auto complete search in asp.net.



Description:-


         Using AutoCompleteExtender you can attach to any TextBox with minimum character. In TextBox when User Types Prefix Text then it will call the webservices and that Webservice will Return the List that are Display as Popup Below the the TextBox.

Description of the property of the AutocompleteExtender Control:-

TargetControlID - The TextBox control in which the user types content to be automatically auto completed.

EnableCaching- Caching is turned on, so typing the same prefix multiple times results in only one call to the web service. It is true or false.

MinimumPrefixLength- Minimum number of characters that user must have to entered before getting suggestions from the web service.

CompletionInterval - Time in milliseconds when the timer will call Tick in to get suggestions using the web service.

CompletionSetCount - Number of suggestions will be retrieved from the web service.

 


To show Example of Popup in Ajax click Here Modal Popup in Ajax with Asp.Net

to Show example of Nested Popup Click Here Nested Modal Popup in Ajax with Asp.Net

to show Example of AutoComplete TextBox Extender click Here AutoComplete Extender in Ajax with Asp.Net

to show Example of Password Strength Extender click Here Password Strength in Ajax with Asp.Net



Aspx Code:-

<asp:TextBox ID="txtbx_searchtext" runat="server" CssClass="textbox" ValidationGroup="Sub"></asp:TextBox>
                                                <cc1:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteEx" ID="autoComplete1"
                                                    TargetControlID="txtbx_searchtext" ServiceMethod="AutoCompleteSearch" MinimumPrefixLength="2"
                                                    CompletionInterval="100" EnableCaching="true" CompletionSetCount="20" CompletionListCssClass="autocomplete_completionListElement"
                                                    CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
                                                    DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true">
                                                </cc1:AutoCompleteExtender>
 <asp:Button ID="btn_search" runat="server" Text="Search" CssClass="AddButton" OnClick="btn_search_Click" />



Code Behind Code:-

public static string[] AutoCompleteSearch(string prefixText, int count)
    {
using (DataClassesDataContext database = new DataClassesDataContext())
                        {

                            var searchresult = (from smpltest in database.bb_BloodSampleTests
                                                where smpltest.fk_hospitalid == hospid

                                                join smplcoll in database.bb_BloodSampleCollections on smpltest.fk_bloodsampleid equals smplcoll.pk_samplecollectionid into smpltest_smplcoll
                                                from smplcoll in smpltest_smplcoll.DefaultIfEmpty()

                                                join dnreg in database.bb_DonorRegistrations on smplcoll.fk_donorregistrationid equals dnreg.pk_donorregistrationid into smplcoll_dnreg
                                                from dnreg in smplcoll_dnreg.DefaultIfEmpty()

                                                select dnreg.donorid).ToArray();


                            if (searchresult.Any())
                                return searchresult.Distinct().ToArray();
                            else
                                return null;
                        }

}

0 comments:

Post a Comment