jeudi 24 décembre 2015

Last input values passed to action in MVC

I want to generate table with, for example, 4 columns. In last column i need link to remove user whitch is in that row. When i am using form tag like this:

@foreach (var item in Model.Approvers)
{
<tr>
    <td>@item.FullName</td>
    <td>@item.Email</td>
    <td>@item.AdAccount</td>
    <td>
        <form id="removeApproverRoleForm" action="~/Admin/RemoveRole"     method="post">
            @Html.AntiForgeryToken()
            <input type="text" id="userId" name="userId" value="@item.Id" />
            <input type="text" id="role" name="role" value="Approver" />
            <a href="#" id="removeApprover" class="button">Remove</a>
        </form>
    </td>
</tr>
 }

It passes last value of userId and role to RemoveRole method. It have to be POST method so this whould not work:

@Html.ActionLink(Remove, "RemoveRole", "Admin", new { role = "Approver", userid = item.Id }, new { onclick = "return removeRole();" })

Even if i place form tag above that, the parameters are still visible in the link.

So i need somehow use new { role = "Approver", userid = item.Id } but send it as a POST and hide those values.

Any ideas? Thank you for help!




Aucun commentaire:

Enregistrer un commentaire