0
I have a code that queries a Webapi, writes to the database, and queries the database, in this application, a view that has 3 buttons, namely:
- Consult Ws
- Inserts BD
- Comic book consultation
I am using @Html.Beginform to submit the button action and call the responsible Actionresult for each processing.
In passing parameters, only one action is allowed (obviously). How do I make you have "a decision-making" or an "if", so that you call the correct action by clicking on its respective button?
Would it be better to use another form type? Or any other forms for this?
In the code below the "Consultaws" is the parameterized action that "should change" when clicking on a button other than "btnCsWs".
@using (@Html.BeginForm("ConsultaWs", "Home", FormMethod.Get))
{
<text>codigo do país</text>
@Html.TextBoxFor(model => model.RestResponse.result.country)
<text>codigo do estado</text>
@Html.TextBoxFor(model => model.RestResponse.result.abbr)
<button type="submit" name="btnCsWs">Consulta WS</button>
<button type="submit" name="btnInsereDB">Insere DB</button>
<button type="submit" name="btnCsDB">Consulta DB</button>
}
Mauricio, you can put an id on the button and make a Javascript call for when clicked change the form action
– José Francisco