Button/link inside a view redirecting to another view

Asked

Viewed 6,021 times

1

I have the following address for a view:

http://localhost/Configuracao/Details/1

Where create a button/link that redirects to another address from another view as follows:

<a href="@Url.Action("~/Views/Ativos/Index", Model.Id)" title="Visualizar" class="btn btn-info">
     <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
      Ativos 
</a>

Only by clicking the address:

http://localhost/Configuracao/~/Views/Ativos/Index

How to do this steering?

  • Have you tried calling the Active Controller View Index directly? href="@Url.Action("index","Active", Model.Id)"

  • Do you want to pass the ID parameter along with the URL? Getting http://localhost/Assets/Index/1?

  • @Renilson Andrade Ih comrade all right!? I’m Jothaz remember? That was it! It worked. Elaborate the answer so I mark as correct. And thank you very much!

  • I missed the H in the name, but I remember yes, this avatar helped me a lot. I’m glad I could reciprocate in a small way.

2 answers

5


You can call the View Index directly from the Active Controller:

 <a href="@Url.Action("Index", "Ativos", Model.Id)" title="Cancelar" class="btn btn-info">
         <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
          Ativos 
    </a>

3

You don’t have to use @Url.Action:

<a href="/Ativos/Index/@Model.Id" title="Cancelar" class="btn btn-info">
     <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
      Ativos 
</a>
  • 1

    Thank you is always nice to have several views of how to solve a problem.

Browser other questions tagged

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