Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Bruce 103 posts 437 karma points
    16 days ago
    Tom Bruce
    0

    Hi everyone, I have an ActionLink to call a delete method within a controller

    @Html.ActionLink("Delete", "Delete", new { Id = d.ID })
    

    The problem is a ActionLink is an Get method and I can’t do a return CurrentUmbracoPage() form a Get method.

    The ActionLink is generated within a table to delete records.

    Any ideas how I can call a deleted method within a controller and then return the user back to the same page?

    Tom

  • Nik 893 posts 3561 karma points MVP c-trib
    16 days ago
    Nik
    100

    Hi Tom,

    You could work around it by using a form and a post method.

    If you did something like

    <form action="@Url.ActionLink("Delete", "Delete") method="POST">
         <input type="hidden" value="@d.ID" name="Id" />
         <button type="submit">Delete</button>
    </form>
    

    And then styled the form and button to look like a link.... that could work around it.

    Although to do it properly you'd want to use @using(Html.BeginUmbracoForm.... (Sorry don't have the full syntax for this at hand) to generate the form tags. As this would do the full Umbraco routing and I'm not sure the first option would.

    Thanks

    Nik

  • Tom Bruce 103 posts 437 karma points
    14 days ago
    Tom Bruce
    0

    Hi Nik,

    Within the controller how would I get the value="@d.ID

    Tom

Please Sign in or register to post replies

Write your reply to:

Draft