Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 363 posts 917 karma points
    Apr 17, 2015 @ 10:46
    Craig O'Mahony
    0

    ActionLink as an Images

    Hi all,

    Firstly apologies as this is about the millionth question I've asked recently but I'm being outwitted by MVC!

    What I'm trying to do is this:

    I've got a search box with a search icon next to it.

    If a user types something in the search box and presses enter then httppost method is called on the controller (the value that the user has entered is passed to this method).

    What I'd like to be able to do is replicate this exact behavior when the user types something and then clicks on the search image (without pressing enter).

    This is what I've done so far (which obviously is completely wrong!)

    @using (Html.BeginUmbracoForm<STEP_Umbraco.Controllers.CourseController>("Find"))
    {
        @Html.TextBox("zSearchTerm", TempData["SearchString"], new { id = "txtSearch", @class = "search", placeholder = "Search" })
        @Html.ActionLink(".", "Find", "course", new { @class = "search-icon" })
    }

    What happens when I click the search image (@Html.ActionLink) I get the error of The resource cannot be found (Requested URL: /umbraco/Surface/Course/Find)

    Any help would be great :)

    Thanks,

    Craig

  • Tim 1193 posts 2655 karma points c-trib
    Apr 17, 2015 @ 17:41
    Tim
    101

    Replace your ActionLink with a good old fashioned HTML Image Button and it should just submit the form and work.

  • Craig O'Mahony 363 posts 917 karma points
    Apr 17, 2015 @ 17:51
    Craig O'Mahony
    0

    Turns out I'm overthinking everything!

    Cheers matey

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies