ASP.Net AJAX Extender - List Search Box

2/29/2008

If you do web development and work with ASP.Net, most likely you've also been using their AJAX implementation and probably also their Control Toolkit. I've been using it for a while now and I have to say that most of the time I have to tweak or even reinvent one of their items because of their implementation. One such item was the ListSearchExtender. It worked perfectly well but I found that quite a few people never used the feature because they didn't pay attention to the text that popped up even if an explanation was above the list.

To mitigate that issue I found that using a text box with text above it explaining its purpose fixed that problem. Another issue that I found was that sometimes a design called for an item in a list to be indented. This can be done by adding code similar to this:

1: ListItem IndentedItem = new ListItem();

2:string EncodedString = "&#160;&#160;&#160;&#160;";

3: System.IO.StringWriter Writer = new System.IO.StringWriter();

4: HttpUtility.HtmlDecode(EncodedString, Writer);

5:string DecodedString = Writer.ToString();

6: IndentedItem.Text = DecodedString + DecodedString+"Item Name";

And adding that to the list. This however makes the item completely unsearchable as the ListSearchExtender does not take into account HTML encoding nor are you capable of specifying characters to ignore from what I can tell. This also meant that I had to develop my own version of that item. And to help others so that they don't have to reinvent the wheel (although they may still want to tweak this code as there is little optimization done), I'm giving you the code:

You might want to note that the extender was created in a seperate project for my various AJAX extenders called AJAXControls and also within its own directory called FilteredSearchBox. So you might have to change some stuff around to use this. Also the designer file was left blank. So when you create the extender you can pretty much ignore that portion. Anyway, I have quite a few other extenders that I've created and as far as I'm aware they should all work with 2.0 as well as 3.5, so expect every once in a while to pepper the site with these from time to time.