@Html.Actionlink submitting Post MVC form

Asked

Viewed 640 times

2

@using (Html.BeginForm("MinhaAction", "MeuController", FormMethod.Post ))
{
    <div>
        <table>
            <thead>
                <tr>
                    <th>Empresa</th>
                    <th>Cliente</th>
                    <th>Situação</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td><a href="@Url.Action("MinhaAction", "MeuController", item)">@item.Empresa</a></td>
                        <td><a href="@Url.Action("MinhaAction", "MeuController", item)">@item.Cliente</a></td>
                        <td><a href="@Url.Action("MinhaAction", "MeuController", item)">@item.Situacao</a></td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

Is it possible to submit a form this way? What is the solution to this question?

  • I don’t understand. What problem faced?

  • My intention was that the user clicking on any cell data of this table the system would have to save this object and pass to my View via Post without for that I add a button (with Submit) in this table.

1 answer

1

No. There is a fierce confusion of concepts there.

A form POST sends information from a form using the data submission protocol. Clicking a link is a request GET that sends information through the requested HTTP address.

What you want to do, probably, is to typify some information to be sent. This can be done using some information component, such as a radiogroup (@Html.RadioButton() or else @Html.RadioButtonFor()) and treating the field in Action.

Don’t forget to put the button submit:

<button type="submit">Enviar</button>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.