How to pass ID via Javascript to a View

Asked

Viewed 291 times

1

In the application I am developing use Views of the type modal.

Use this code to display the modal:

<button class="btn btn-default details" data-id="@clientes.Codigo"><i class="glyphicon glyphicon-file"></i></button>

$(".delete").click(function () {
    var id = $(this).attr("data-id");
    $("#modal").load("Excluir?id=" + id, function () {
        $(".modal").modal();
    })
});

We see that my Modal use a "data-id" to pass the value of the ID, my problem is this, I need to do something similar but I will not use a modal rather a View normal, as would be mine javascript for that reason?

  • I could use a onclick="location.href='@Url.Action("Cadastro", "Cliente")'" but I don’t know how to add a parameter to this link

1 answer

2


I wouldn’t even need to use Javascript. A normal link already solves everything.

onclick="location.href='@Url.Action("Cadastro", "Cliente", new { id })'"
  • 1

    It was very simple, but it helped me a lot. Thanks again for your collaboration.

Browser other questions tagged

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