views:

849

answers:

1

I'm trying to convert an app that I had previously written in ASP.NET Web Forms to MVC and am stuck on the problem of implementing an autocompleting combobox. Previously, I had used Telerik's RadComboBox, but I'm not sure how to make this work in MVC or if it even can be made to work. Here's the markup code I was using:

<telerik:RadComboBox ID="Brand" runat="server" Width="250px" EmptyMessage="Choose a brand" EnableLoadOnDemand="true" OnItemsRequested="Brand_OnItemsRequested" />

And the code-behind:

protected void Brand_OnItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
  foreach (BrandCode b in _repository.GetBrandCode(e.Text).OrderBy(b => b.BrandName).Take(10))
  {
    Brand.Items.Add(new Telerik.Web.UI.RadComboBoxItem(b.BrandName, b.BrandCode1));
  }

  Brand.DataBind();
}

Any ideas appreciated.

+4  A: 

We do this at work by simply populating a drop down list (or combobox, whichever tickles your fancy), and then using jquery's autocomplete by doing something like $('#myddl').autocomplete();

Kezzer
+1 for the autocomplete plugin. I use it a lot.
tvanfosson