Copied to clipboard

Flag this post as spam?

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


  • Niels Lynggaard 192 posts 550 karma points
    Nov 30, 2014 @ 13:27
    Niels Lynggaard
    0

    Help figuring out how to structure search partial, results-page and strongly typed views

    Hi Guys.

    I'm working with Umbraco MVC for the first time, and I'm trying to figure out how to tie my things together in relation to a search partial view and a page with both a search form (partial view) and a result list (partial view).

    The Situation:

    I have on the frontpage (And other places) a partial view "Search" that displays a complex search-form. This partial view is rendered through  @Html.Action("Index","SearchSurface"), hence the SearchSurfaceController returns a strongly typed partial view, that is bound the the model "Search". This model contains various properties for the form to use.

    The form in partial view Search.cshtml using @using (Html.BeginForm("Search", "SearchSurface")){ .... } hence it posts to the controller action "Search" on the "SearchSurfraceController". This action, however, I'd like to make so that it redirects to /Soeg-Bolig/Resultat wich is actually a page in Umbraco, using the template "Resultat" wich at the moment is a UmbracoViewPage. That inherits from a base layout of type "UmbracoTemplatePage".

    So, here are the golden questions:

    1) How can I make the action "Search" in SearcSurfaceController redirect to the Resultpage and at the same time parse the "Search"-object to that view so that it can render both a search-box and a resultlist based on this model?

    2) How can I make the view "Result" strongly typed?

    a) If I use UmbracoViewPage<>, then i need to wrap my custom model in a viewmodel that inerhits from RenderModel. I've tried going down this path, but I end up having problems with figuring out the IPublishedContent item for what page is beeing rendered, propably since /SearchSurface/Search is not a page..

    b) If I make the view inherit from UmbracoTemplatePage then I need to wrap my custom model in some sort of IPublishedContent to strongly type the view to my model.

    I'd be VERY gratefull for anything that can point me to the proper way to do this, since I'm going around in circles at the moment. I guess the questions summed up are;

    How can I make my form post to wich controller to be able to show 2 controls on the page "result" based on the same model?

    Looking very much forward to ideas here!

    Cheers,

    Niels

Please Sign in or register to post replies

Write your reply to:

Draft