Jquery UI autocomplete in Asp.net MVC


A nice feature of the JQuery library is its autocoplete feature. So when we start typing into an html input text, it is a feature that offers us some suggestions. The suggestion lists we frequently see in search engines can give us an idea.

In order to perform this operation, the action method to be used by JQuery must be prepared.

The method we use is the Search action method. So when we make an entry in the text box, JQuery will automatically bring the results to us by searching the Search () method and searching for the text in the names list. For live applications, instead of using a list like here, we can access the database and get the actual data.

 

Now go to the Index view page and continue by creating a text box.

The content of our ndex view page should be as above. Let’s talk about what we do.

First of all, we have received all the autocomplete elements using a multiple selector such as $ (olan: input [data-autocomplete] multiple). Then, we took a stroll through each of these elements. Since the Autocomplete mechanism is a control that needs a source (data source), whichever text input is to give the autocomplete property, we define a property in the name of data-autocomplete. Then we specify the source we want to give to this feature. Here we specify the Search action method of the Home controller class. This way, the Search method is triggered automatically when we overwrite input text.

 

 

if you have question do not forget to write from the chat button next to it or from the comment

You may also like...

Leave a Reply

Your email address will not be published.