2
I’m having trouble calling Actionresult using input type="submit"
and pass the model data.
I did a test using ActionLink
but Model is not sent.
Someone could shed a light?
Here is the code: Controller:
[HttpPost]
public ActionResult Aprovar(FormularioModel model)
{
//Código
}
[HttpPost]
public ActionResult Devolver(FormularioModel model)
{
//Código
}
View:
@using (Html.BeginForm(null, "Domiciliacao", FormMethod.Post, new { id = "formFila" }))
{
@Html.Partial("~/Views/Shared/ViewPartial.cshtml", Model) //PartialView sendo carregada para complentar os dados da tela.
//Código
<div>
<input type="submit" value="Aprovar" name="Aprovar" formmethod ="post" formaction="~/Domiciliacao/Aprovar" class="btn btn-success btn-lg"/>
</div>
<div>
<input type="submit" value="Devolver" name="Devolver" formmethod ="post" formaction="~/Domiciliacao/Devolver" class="btn btn-danger btn-lg"/>
</div>
}
Tried to name the action?
– Aline
This is ASP.NET Core?
– Jéf Bueno
Aline: yes I did, but I have more than one action. - Jbueno: MVC4
– Luiz Martinez
So how do you define which action you’re sending?
– Aline
Through the formaction
– Luiz Martinez
Yes, I saw him there. But you assign the attribute value of the pro form button at what point? With js?
– Aline
Sorry, I don’t understand. I’m beginner in WEB development.
– Luiz Martinez
Don’t you have a code that assigns the attribute value: formaction para action to the form? All your code is the one you posted?
– Aline
It’s not all, but if you’re referring to some <script>, I don’t have it in this view. I want to call Action passing the whole Model, with the changes that were made.
– Luiz Martinez