1
I have a controller, in this Controller
has a action
List, to which it returns all suppliers.
In the view
List, I created one input type="search"
. I want that when searching a name in this field, it returns the name, or all names, which was typed in the search, in the same view, ie in the same table. The only way I could find to do that is to create a action
Search, and create this view
Research.
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>