Copied to clipboard

Flag this post as spam?

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


  • Ras 64 posts 328 karma points
    Jun 09, 2022 @ 07:56
    Ras
    0

    Persisting data in form fields after form submission

    I'm trying to have a form where if you select a certain option, we'll submit the form but also reload the page with all or most of the data in the fields intact so that you can submit the form again with similar data without having to fill out all the fields again. Problem is, the form is a partial view rendered inside a view, so if we try to return the view like return View(model) or any similar methods really, there is either an error or the page is loaded as raw htlm without any css (for some reason).

    I also attempted to use both TempData and ViewBag, but whenever I set the value of the fields to either of these, the value tag in the html doesn't even appear.

    The form is created with Html.BeginUmbracoForm and using a surface controller to handle the submission, which is where I try to set the TempData/ViewBag values that I pass to the view.

    Any ideas? Thanks!

  • Ras 64 posts 328 karma points
    Jun 09, 2022 @ 11:07
    Ras
    100

    Hi, I ended up using the HTTP session-state object for this. Not my favourite solution but it works.

Please Sign in or register to post replies

Write your reply to:

Draft