Redirect to a page with its corresponding id

1

Implement this code so that it works as it should be, when pressing the button, direct me to an entry corresponding to that id. My idea was this but it is clear that it is wrong.

<button class="btn btn-xs btn-default" title="Editar" 
onclick="location.href='@Html.ActionLink("EDITAR", "Details", new { id = item.PKDATOS })'">
  <i class="fa fa-file-pdf-o"></i>
  </button>
  <button class="btn btn-xs btn-default" title="Editar" onclick="location.href='@Html.ActionLink("EDITAR", "Edit", new { id = item.PKDATOS })'">
  <i class="fa fa-edit"></i>
  </button>
  <button class="btn btn-xs btn-default" title="Eliminar" onclick="location.href='@Html.ActionLink("ELIMINAR", "Delete", new { id = item.PKDATOS })'">
  <i class="fa fa-trash-o"></i>
  </button>

The result that gives me in the browser is this:

link

and should be:

link

    
asked by DC-Rom 13.11.2018 в 17:38
source

4 answers

0

Thanks for the answers, but none worked, looking for I found the solution to my problem which is:

<button class="btn btn-xs btn-default" title="Detalles" onclick="location.href='@Url.Action("Details", "DATOS", new { id = item.PKDATOS })'">
 <i class="fa fa-plus"></i>
</button>
<button class="btn btn-xs btn-default" title="Editar" onclick="location.href='@Url.Action("Edit", "DATOS", new { id = item.PKDATOS })'">
<i class="fa fa-edit"></i>
</button>
<button class="btn btn-xs btn-default" title="Eliminar" onclick="location.href='@Url.Action("Delete", "DATOS", new { id = item.PKDATOS })'">
<i class="fa fa-trash-o"></i>
</button>
    
answered by 15.11.2018 / 19:32
source
0

Try this code.

<input type="button" value="Go Somewhere Else" onclick="location.href='<%: Url.Action("Action", "Controller") %>'" />
    
answered by 13.11.2018 в 17:39
0

The URL that is being generated is, after decoding it:

http://localhost:9860/<a href=\"/Usuario/Delete/1\">ELIMINAR</a>

The problem is that @Html.ActionLink generates a tag <a> , if you want only the URL change it for @Html.Action only.

    
answered by 13.11.2018 в 17:56
0

Dear, the error has it in q you have not placed q Action and q Controller you have to go the correct way is this:

<button class="btn btn-xs btn-default" title="Edit" onclick="location.href='@Url.Action("Edit", "EditController", new { id = item.id})'">

Edit is the action and EditController is the controller you want to go to (ControlController, the suffix Controller is not necessary). thanks !!

    
answered by 24.11.2018 в 18:55