First, the target markup:
No custom properties whatsoever, just an handler for the AutoFill event, which will be called whenever the fill function is invoked.
The AutoFillDropDownList inherits from DropDownList:
Again, for client callbacks, we need to implement ICallbackEventHandler. In its RaiseCallbackEvent we raise the AutoFill event, store its output in the request itself (HttpContext.Items collection), and on GetCallbackResult, we take this value and pass it to the client.
Another important thing is, whenever there is a postback, we need to raise the AutoFill event again, because the drop down must be in a consistent state, therefore we need to get its items. We do that in the PreLoad event of the page.
The AutoFill event uses a special argument:
Results: the key-value pairs that will be used to fill the drop down list items.
A typical handler might look like this:
There are no dependencies on any external libraries other than Microsoft AJAX Library, which is included by the ScriptManager.
Hope you like it!