Copied to clipboard

Flag this post as spam?

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


  • Christina 111 posts 344 karma points notactivated
    May 29, 2018 @ 08:36
    Christina
    0

    Help with querystring

    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 428 posts 2354 karma points MVP 3x 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 428 posts 2354 karma points MVP 3x 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 111 posts 344 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 428 posts 2354 karma points MVP 3x 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 111 posts 344 karma points notactivated
    May 29, 2018 @ 14:36
    Christina
    0

    Many Thanks

  • 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