Copied to clipboard

Flag this post as spam?

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


  • Christina 127 posts 390 karma points notactivated
    May 29, 2018 @ 08:36
    Christina
    0

    Hi i need some help I have implemeted the search from https://codeshare.co.uk/blog/how-to-search-by-document-type-and-property-in-umbraco/

    I want to pass the to the /search?query=something take and the query value from the Request.QueryString and pass it to the RenderForm action.

    Can someone help me Thanks in advance Christina

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 29, 2018 @ 10:47
    Paul Seal
    2

    Hi Christina

    In the view you can add something like this

    @{
        string searchTerm = Request.QueryString["query"];
    }
    

    Then when you call the render action you can pass it in like this

    @{ Html.RenderAction("RenderSearchForm", "Search", new { searchTerm =  searchTerm }); }
    

    And in the action you can pick up the value in the constructor like this

    [HttpGet]
    public ActionResult RenderSearchForm(string searchTerm)
    {
        //code in here
    }
    

    I hope that helps.

    Paul

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 29, 2018 @ 11:10
    Paul Seal
    0

    Although just having query in the Action should work without the rest of it.

    [HttpGet]
    public ActionResult RenderSearchForm(string query)
    {
        //code in here
    }
    
  • Christina 127 posts 390 karma points notactivated
    May 29, 2018 @ 11:17
    Christina
    0

    Hi Paul Many thanks I really appreciate your videos. Another question If i want the searchform in the header what should i do /Christina

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 29, 2018 @ 13:42
    Paul Seal
    101

    You're welcome.

    You could just add a simple form like this in the header.

    <form action="/search/" method="GET">
        <input type="text" placeholder="Search..." name="query">
        <button>Search</button>
    </form>
    

    Kind regards

    Paul

  • Christina 127 posts 390 karma points notactivated
    May 29, 2018 @ 14:36
    Christina
    0

    Many Thanks

Please Sign in or register to post replies

Write your reply to:

Draft