How to pass parameter via button

2

How do I use the text of @Html.TextBox("pesquisa") as a parameter in the code below

<button id="BtnConsulta" onclick="location.href='@Url.Action("Pesquisa", "Cliente", new { PARAMETRO)'"><i class="glyphicon glyphicon-search"></i></button>

</div>
<div class="editor-field">
    @Html.TextBox("pesquisa")
</div><br />
    
asked by anonymous 22.10.2015 / 02:16

1 answer

5

Make sure your form is using the GET method:

@using (Html.BeginForm("Pesquisa", "Cliente", FormMethod.GET)) 
{ 
    <div>
        <button id="BtnConsulta" name="parametro" value="valor" type="submit">
            <i class="glyphicon glyphicon-search"></i>
        </button>
    </div>
    <div class="editor-field">
        @Html.TextBox("pesquisa")
    </div>
}

Make sure that your button has name , value , and is submit .

        <button id="BtnConsulta" name="parametro" value="valor" type="submit">
            <i class="glyphicon glyphicon-search"></i>
        </button>

onclick does not need.

    
22.10.2015 / 04:11