Copied to clipboard

Flag this post as spam?

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


  • hakan 24 posts 118 karma points
    Nov 21, 2018 @ 14:15
    hakan
    0

    Can I send Data to umbraco page from controller

    I cant pass my "filtered search results list" to view. please help me.

    public class searchResultsController :  SurfaceController
    {
        // GET: searchResults
        [HttpPost]
        public ActionResult SearchResults(string searchText)
        {
            if (searchText=="")
            {
                return CurrentUmbracoPage();
            }
            List<searchResultModel> searchResult = new List<searchResultModel>();
            foreach (var result in Umbraco.TypedSearch(searchText, useWildCards: true))
            {
                if (result.TemplateId !=0)
                {
                searchResultModel s = new searchResultModel();
                s.Name = result.Name;
                s.Url = result.Url;
                searchResult.Add(s);
                }
            }
            return View(searchResult);
        }
    }
    
  • Al Burns 49 posts 149 karma points
    Nov 21, 2018 @ 14:40
    Al Burns
    0

    Hi hakan.

    What I would do here is create a search results document type, template and controller derived from RenderMvcController which will accept the search term from the query string, perform the search and return the results in a view model to the results page for display.

    Then in your SurfaceController post method, simply create the URL to the search results page, passing the search term as a query string parameter, and call the Redirect method for it.

    Hope this helps.

  • Harry Spyrou 212 posts 604 karma points
    Nov 21, 2018 @ 16:06
    Harry Spyrou
    0

    Hi hakan,

    Do you have a view called SearchResults?

  • 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