Copied to clipboard

Flag this post as spam?

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


  • Stief Dirckx 43 posts 76 karma points
    Jun 20, 2016 @ 11:13
    Stief Dirckx
    0

    ModelState and ViewData inside macro

    Our site editors can include a macro inside the RTE to include a form to participate in a competition or register for an event.

    This macro inherits from PartialViewMacroPage and inside the partial an child action is rendered. This child action contains a form and after posting to a SurfaceController I return to CurrentUmbracoPage() when ModelState is invalid. I also add a message to the ViewBag.

    But both ModelState and ViewBag are lost as soon as I return to the PartialViewMacroPage.

    I tried this solution but the ParentActionViewContext is null inside the PartialViewMacroPage.

    I have a working solution using session variables and merging ModelState but I'm hoping someone has a more clean solution.

Please Sign in or register to post replies

Write your reply to:

Draft