Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:15:58+00:00 2026-06-14T02:15:58+00:00

I am working on a website that allows people to register for events. On

  • 0

I am working on a website that allows people to register for events. On the registration page, I have a form that captures the data, validates in an MVC controller, persists it between Views, and then is supposed to display a preview page.

Below is a simplified example of what I am trying to do.

Person ViewModel

    public class Person{
        public int TitleId {get; set;}
        public SelectList Titles {get; set;}
    }

Register Controller

    public class RegisterController:Controller
    {
        [HttpGet]
        public ActionResult Register(){
            return View(new Person());
        }

        [HttpPost]
        public ActionResult Register(Person person){
            if(ModelState.IsValid){
                TempData["Person"] = person
                RepopulateSelectLists(); //Gets the data for the select list again
                return RedirectToAction("Preview");
            }
            return View();
        }

        [HttpGet]
        public Actionresult Preview(){
            Person person = (Person)TempData["Person"];

        }
    }

Preview View

    @Html.DisplayFor(m => m.TitleId);  //Will display int, not selected value

Assuming my SelectList has all of the values, and I have the key/Id of the value selected on the previous page, how do I redisplay just the text of what they selected?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:16:00+00:00Added an answer on June 14, 2026 at 2:16 am

    It doesn’t work that way. In your Preview() page you’d take the given ID and find its associated name. You’ll likely want to build a custom View Model (VM) in this case to keep the ID and the Name in the VM.

    Also, the moment you hit F5 on the preview page, everything will be GONE. TempData doesn’t persist and any refreshing of the page will lose the data.

    I would recommend, instead, that on successful postback, you just return a different view based on the initial post data. For example:

        [HttpPost]
        public ActionResult Register(Person person){
            if(ModelState.IsValid){
                RepopulateSelectLists(); //Gets the data for the select list again
                var previewVM = new PreviewVM();
                // populate it with the model or whatever else you need for the preview
                return View("Preview", previewVM);
            }
            return View();
        }
    

    An example VM of a person

    public class Person { public int TitleId { get; set; } }
    public class PersonVM : Person { public string TitleName { get; set; } }
    // ... then in your Register method
    var previewVM = new PersonVM { TitleId = person.TitleId, TitleName = GetTitle(person.TitleId) };
    

    Assuming GetTitle does a lookup based on the TitleID. It’s very coarse code, but I hope you get the gist of it. THen you’d use Html.DisplayFor(m => m.Title); And if your preview has a post to the next page, you’d want to have Html.HiddenFor(m => m.TitleId) to make sure the value passes on but you’d have to do that even with your current method. Alternatively you could store the Title in the ViewBag (or ViewData -- same thing) and simply not useDisplayForto display the value and pass in the value from theViewBag`

    Notice I scrapped the "Preview" method completely. That way, if you hit F5 at this point, it just re-posts with the same data you used to get to the preview page. And assuming you’re not saving (I don’t see where you are) then there’s no harm in posting back. Make sense?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have an ASP.NET MVC 3 website that allows people to advertise certain
I'm working on a website that allows people who run bed and breakfast businesses
I'm working on a company website that allows users to have their own homepage
I just started working on a website that will help people understand what rappers
I have a form on a website I'm working ( you can see it
I have a jquery plugin that i'm working with for a website and I
I'm working on a website that allows users to create an account. One of
i have a website that allow people to unsubscribe to other websites (to mailing
I am working on a website that allows users to choose a standard car
I'm working to develop a website that allows clients to log in and see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.