title: Autocomplete for textbox in mvc
body: <p>This is my view and controller. I have converted code from c# to vb the code was working perfectly in C# but i dont know why this java script is not working in vb. I started debugging but controllers never get called when i type something in search box.</p>
  
  <p>Code for View</p>
  
  <pre><code>@ModelType  PrudentHealthCare.Product
  @Code
      Layout = Nothing
  End Code
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta name="viewport" content="width=device-width" /&gt;
      &lt;title&gt;Search&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div&gt; 
          @Using (Html.BeginForm())
              @Html.HiddenFor(Function(model) model.id)
              @&lt;input type="text" id="search" placeholder="Search for a product" required /&gt;
              @&lt;input type="submit" value="Go" id="submit" /&gt;
          End Using
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  &lt;link href="~/Content/AutoComplete/jquery-ui.css" rel="stylesheet" /&gt;
  &lt;script src="~/Content/AutoComplete/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;script src="~/Content/AutoComplete/jquery-1.9.1.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      var url = '@Url.RouteUrl( "DefaultApi" , New With { .httproute = "", .controller = "ProductApi" })';
      $('#search').autocomplete({
          source: function (request, response) {
              $.ajax({
                  url: url,
                  data: { query: request.term },
                  dataType: 'json',
                  type: 'GET',
                  success: function (data) {
                      response($.map(data, function (item) {
                          return {
                              label: item.Description,
                              value: item.Id
                          }
                      }));
                  }
              })
          },
          select: function (event, ui) {
              $('#search').val(ui.item.label);
              $('#Id').val(ui.item.value);
              return false;
          },
          minLength: 1
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>ProductApiController</p>
  
  <pre><code>Imports System.Web.Mvc
  
  Namespace Controllers
      Public Class ProductApiController
          Inherits Controller
  
          &lt;HttpGet&gt;
          Public Function GetProducts(Optional query As String = "") As IEnumerable(Of Product)
              Dim xyz As String
              xyz = query
          End Function
  
      End Class
  End Namespace
  </code></pre>