I m using MVC4. I need a combobox which will allow a user to input a new value if it does not exist, or which will automatically be selected if it exists among the available values.
How can I achieve this ?
@Html.DropDownListFor(Function(model) model.XYZ.Id,
New SelectList(Model.XYZ,
"ID",
"Name",
Model.XYZList.First().Id))
This will generate a dropdownlist , but it won’t allow users to type a new entry.
Thanks
HTML does not have combobox like in windows forms. You should try javascript. Check out jquery autocomplete.
http://jqueryui.com/autocomplete/#combobox