Copied to clipboard

Flag this post as spam?

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


  • Simon 12 posts 43 karma points
    Apr 26, 2013 @ 13:49
    Simon
    0

    Persisting data from one Razor view to SurfaceControlller to another view

    Hey Guys,

    First post and still fairly new to the Umbraco world, but managed to get to grips with most aspects so far. I have run into a problem now though and would like to get your input if I may.

    I basically have a page with a list of items and each item has a link which needs to point to another page with an umbraco form. The form needs to have a pre-populated field based on the link that was clicked on the previous page.

    Which is the best way to  approach this problem? Should I point the links to a SurfaceController method along with the relevant parameter and some how persist it to the next view? I don't know if that's possible in Umbraco - but that's the way I'd approach it from my MVC background.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Apr 26, 2013 @ 14:38
    Dave Woestenborghs
    0

    A surface controller would be a good place to start. From then on you can do most of the things that you are used too with regula MVC

  • Simon 12 posts 43 karma points
    Apr 26, 2013 @ 16:37
    Simon
    0

    Thanks for the reply! Still not having much luck persisting the parameter from the SurfaceController GET method to the view/page. Currently storing it in TempData (also tried the ViewData and ViewBag) for access in the view. Is there another approach that I should be using instead?

    public ActionResult Apply(string vacancyTitle)

    {

                TempData.Add("VacancyTitle", vacancyTitle);

                var ap = uQuery.GetRootNode().GetDescendantOrSelfNodes().Where(x => x.Name == "Application").First();

                return RedirectToUmbracoPage(ap.Id);

    }

  • Simon 12 posts 43 karma points
    Apr 26, 2013 @ 17:15
    Simon
    1

    TempData has miraculously sprung into action and I can now access the values required.

    Not sure what happened there!

Please Sign in or register to post replies

Write your reply to:

Draft