65.9K
CodeProject is changing. Read more.
Home

A client side filtered dropdown for ASP.NET

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.83/5 (6 votes)

Jul 13, 2004

1 min read

viewsIcon

52141

downloadIcon

2002

Filter a combo box in IE as you type - without posting back at every key press

Sample Image - FilteredDropDownList.jpg

Introduction

Internet Explorer's combo box does not have enough functionality. This is one attempt at giving your site users a better experience, especially if combo boxes are related to each other and need to post back, or if your lists are very long, or even unsorted. It can be an irritating experience for the user to scroll up and down for minutes looking for a value to pick.

Using the code

The code is pretty self explanitory, and uses some javascript for client side work. Compile the FilteredDropDownList class into a web control library, and use it like you would use a normal ASP.NET DropDownList, from which the control inherits.

The ValueStartsWithFilterString property indicates if the text typed must be at the start of the text in the combo box, or anywhere in the combo box item’s text. The TextCSSClass property sets the stylesheet class of the textbox where the filter string is typed. The Text property sets the text in the textbox where the filter string is typed.

Points of Interest

This control is for use with Internet Explorer, some other browsers, like FireFox, already have this functionality in their combo boxes. The code was only tested using Internet Explorer 6.