How to pass text or index from a DropDownList
to Controller
at the press of a button?
I tried using @model
and could not.
I tried by adding [HttpPost]
to Controller
and using the submit
button and it did not work.
Controller :
public ActionResult Pesquisar(string _ddl)
{
string opcaoDdl = _ddl;
return View();
}
Index :
@Html.DropDownList("ddlListaUnidades", new SelectList(ViewBag.listaUnidades), new { @class = "dllListaUnidades" })
<div class="botoesfiltrodiv">
<input class="filtro-buttons" type="button" value="Limpar" />
<input class="filtro-buttons" type="button" value="Pesquisar" onclick="location.href='@Url.Action("Pesquisar", "UnidadeAtendimento")'" />
</div>
When I press the button, it even calls controller
, but I can not pass the parameter.