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 122 posts 506 karma points
    Nov 30, 2018 @ 15:28
    Tom Bruce
    0

    ActionLink

    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 1614 posts 7260 karma points MVP 7x c-trib
    Nov 30, 2018 @ 16:53
    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 122 posts 506 karma points
    Dec 02, 2018 @ 17:57
    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