Home > ASP.net > Using AutoCompleteExtender in asp.NET

Using AutoCompleteExtender in asp.NET

//SERVICE  Example: extenderService.asmx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

/// <summary>
/// Summary description for AutoCompleteService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX,
uncomment the following line.

public class AutoCompleteService : System.Web.Services.WebService {

public AutoCompleteService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetSubName(String prefixText)
{
DataClassesDataContext dc = new DataClassesDataContext();

return dc.SUB_TYPEs.Where(stype =>
stype.SUB.sub_name.StartsWith(prefixText)).OrderBy(stype =>
stype.SUB.sub_name).Select(stype => stype.SUB.sub_name).Take(12).ToArray();
}

}

//TEXTBOX declaration in any .aspx

<asp:TextBox ID="TextBoxFilterTxt"  runat="server" Width="712px"></asp:TextBox>
<asp:AutoCompleteExtender ID="TextBoxFilterTxt_AutoCompleteExtender"
runat="server" DelimiterCharacters="" Enabled="True"
TargetControlID="TextBoxFilterTxt"
ServicePath="~/AutoCompleteService.asmx" ServiceMethod="GetSubName"
MinimumPrefixLength="3" CompletionSetCount="12" EnableCaching = "true"
ShowOnlyCurrentWordInCompletionListItem="true">
<Animations>
<OnShow>
<Sequence>
<OpacityAction Opacity="0" />
<HideAction Visible="true" />
<Parallel Duration=".1">
<FadeIn Duration=".5" Fps="20" />
</Parallel>                                                        
</Sequence>
</OnShow>
<OnHide>
<Parallel Duration=".4">
<FadeOut />
</Parallel>
</OnHide>
</Animations>
</asp:AutoCompleteExtender>

THIS IS IT :o )
Advertisement
Categories: ASP.net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.