Appendix autocomplete to TextBox without jQuery and Ajax



  • Hello, everyone!

    I've had a problem like this: I can't find a solution to how to do it. AutoCompleteTotal ASP .NET (live search) without jQuery and without Ajax

    I mean, WinForms would be like,

    textBox1.AutoCompleteCustomSource = source; 
    textBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
    textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
    

    TextBox data I want to take from String[]♪ Maybe someone's gonna throw a tutorial.

    Thank you!



  • In html, there's a gist called datalist. You're on the list of values, and then the identifier of this datalist'a writes a list of your text field in the atribut. After that, your text field is working like a fascinating list, the contents of the cohoro are drawn from the datalist'a, which you can fill out anything. Example:

    <input list="mylist">
    

    <datalist id="mylist">
    <option value="First">
    <option value="Second">
    <option value="Third">
    </datalist>

    Same example https://jsfiddle.net/u8myL7u0/ The use of ajax is not necessary (although if you wish it could be attached to the datalist'a and by request), it can be filled at the back page on the server.

    Example for ASP. NET:

    <input list="mylist">

    <datalist id="mylist">
    <%
    foreach (var str in Strings)
    {%>
    <option><%= str%></option>
    <% } %>
    </datalist>

    Where Strings is your set of lines. For example:

        public string[] Strings
    {
    get
    {
    return new[]
    {
    "First",
    "Second",
    "Third",
    "Fourth"
    };
    }
    }




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2