0

I am trying to use the @Html.TextBox() to get the input from the user, but it should act as an auto complete text box?

Values for the text box will be loaded at page load.

Any idea, how to do this?

user2238971
  • 151
  • 1
  • 1
  • 7

2 Answers2

0

Use jQuery autocomplete plugin described http://jqueryui.com/autocomplete/

This sample gets the autocomplete suggestions via JSON from serer.

Implement Controller and Action to return JSON and query the database for suggestions.

Usually i have UtilitiesController for this kind of Actions, i also recommend writing an extension method for creating AutoCompleteBox, then you can use it @Html.AutoCompleteboxFor(...

Dejan Dakić
  • 2,418
  • 2
  • 25
  • 39
  • Is there anyway to implement auto complete textbox without jquery plugin? – user2238971 Jun 24 '13 at 11:59
  • You can do it manually with javascript, but there is really no need for it, since you have jQuery. If you dont like jquery you can use other libraries containing autocompletebox functionality – Dejan Dakić Jun 24 '13 at 12:01
  • Thanks for your help. I tried it with the JQuery autocomplete Using Jquery plugin we are directly using the input tag like this for the text box element. But how to implement it with the @HTML.TextBox helper in MVC? – user2238971 Jun 24 '13 at 13:00
  • look at my post at this question: http://stackoverflow.com/questions/17185596/how-can-a-decimal-format-to-sting-in-mvc-avoiding-the-last-two-zero-s-after-the/17186021#17186021 this is for another case, but still. – Dejan Dakić Jun 24 '13 at 14:56
0

Try this

$(document).ready(function () {
  $("ControlID").attr('autocomplete', 'off');
});
Amit
  • 15,217
  • 8
  • 46
  • 68