Search for an item in the Aspnet mvc List

1

I have a ControllerFolder, in that Controller has a action List, which it returns all the providers.

In view List, I created a input type="search" . I want when searching for a name in this field, it returns the name, or all names, that was typed in the search, in the same view, that is, in the same table. The only way I found it to do this is to create a action Search, and create this view Search.

 public ActionResult Listar()
    {
        IList<Fornecedor> listaDeFornecedor = new List<Fornecedor>();
        Fornecedor objFornecedor = new Fornecedor();
        listaDeFornecedor = objFornecedor.ListarTodos();
        return View(listaDeFornecedor);
    }
<input type="search" />
<div class="table-responsive">
   <table class="table">
      <thead>
         <tr>
            <th>@Html.DisplayNameFor(model => model.Id)</th>
            <th>@Html.DisplayNameFor(model => model.Nome)</th>
            <th>@Html.DisplayNameFor(model => model.TelefoneResidencial)</th>
            <th>Ações</th>
         </tr>
      </thead>
      <tbody>
         @foreach (var item in Model)
         {
         <tr class="info">
            <td>@Html.DisplayFor(model => item.Id)</td>
            <td>@Html.DisplayFor(model => item.Nome)</td>
            <td>@Html.DisplayFor(model => item.TelefoneResidencial)</td>
            <td>
               <a href="@Url.Action("Detalhes", "Fornecedor", new { id = item.Id })" rel="tooltip" class="fa fa-gear fa-2x" title="Detalhes">
               </a>

               <a href="javascript:Editar(@item.Id)" rel="tooltip" class=" fa fa-pencil-square-o fa-2x" title="Editar fornecedor">
               </a>
               @*<a href="javascript:Excluir(@item.Id)" rel="tooltip" class="fa fa-power-off fa-2x" title="Excluir fornecedor">
               </a>*@

               @*<a onclick="MensagemConfirma('Atenção', 'Deseja Apagar O cliente')", href="@Url.Action("Confirma", "Fornecedor", new {id = item.Id })" rel="tooltip" class="fa fa-power-off fa-2x" title="Excluir fornecedor">
               </a>*@
               <button type="submit" class="fa fa-power-off fa-2x" onclick="MensagemConfirma('Atenção','Deseja Apagar O Fornecedor '+ @item.Id, '@Url.Action("Confirma","Fornecedor", new {id = item.Id })')"></button>
            </td>
         </tr>
         }
      </tbody>
   </table>
</div>
    
asked by anonymous 14.12.2017 / 00:55

0 answers