Microsoft has swifted away from Ajax Library and they are promoting jQuery as the primary way of develop client side ajax applications. This is good news, Microsoft is even contributing resources to the jQuery core team.
A couple of weeks ago i showed how you could use Ajax Library Autocomplete component with Asp.Net MVC. This time I will instead show you how to make the new Autocomplete component in jQuery UI 1.8 play well with Asp.Net MVC, and it's a lot easier than with Ajax Library!
|1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17||
|1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21||
I've included the select event, which will fire when the users has selected an item, in which you can load more stuff etc. Be sure to check out the API for autocomplete for more events and properties.
If you look at the Autocomplete controller you see that I query my User table where the Users name starts with the incoming term. We select only the id and the name from the user (you can select more stuff if you want to make it available in your jQuery events). I only take 10 items, make an array of them which we return as Json.
Important to note is that we have to add "JsonRequestBehavior.AllowGet" argument to the Json() function because jQuery UI Autocomplete makes a Get request and Asp.Net MVC by default doesn't allow this because of the security concerns.