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 6147099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:03:19+00:00 2026-05-23T19:03:19+00:00

I’m implementing a two-step wizard-like process on a web page. The operation is reassigning

  • 0

I’m implementing a two-step wizard-like process on a web page. The operation is reassigning a student to another teacher. Because there are many teachers across many sites, the first step is to choose from a drop-down list of sites. The second step is to choose a teacher at that site.

I have a single view model, StudentReassignmentForm, with properties necessary for each step of the process, like FirstName, LastName, StudentId, TeacherId, SiteId, etc. There’s also a Step property, which keeps track of which step of the process is current. The post handler looks at the step number, and updates the form to show the next step, and then shows a view for that step. The same post method handles each step of the process. Stripped down to its core, my controller methods are:

public ActionResult ReassignStudent(int studentId)
{
  // ... look up student and prepare for step 1 ...

  StudentReassignmentForm form = new StudentReassignmentForm();
  form.Step = 1;
  form.StudentId = studentId;
  form.FirstName = ...;
  form.LastName = ...;
  form.Sites = [IList<Site> of all sites]

  return View("ReassignStudent1", form);
}


[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ReassignStudnet(StudentReassignmentForm form)
{
  switch(form.Step)
  {
    case 1:
      // Prepare for step 2 by looking up teachers at chosen site
      form.Teachers = [IList<Teacher> of teachers at the site]
      form.Step = 2;

      return View("ReassignStudent2", form);
      break;

    case 2:
      // Make final reassignment
      // ...
  }
}

The first step works fine. I can pick the site, and on the postback, form.SiteId is properly set.

The problem is that although I’m explicitly setting form.Step = 2, the view ReassignStudent2 is rendered with step value of 1. Uisng Fiddler, I see that what’s going from the server to the browser is the value 1 (so it’s not the view that’s going wrong somehow).

EDIT: clarified problem in title

EDIT
I’ve done some more experimenting, and found that if I change my view to use Html.DisplayFor(m => m.Step) instead of Html.HiddenFor(m => m.Step), it renders the correct current step value of 2 instead of the old step value of 1. Then I tried Html.EditorFor(m => m.Step), and it produced the incorrect value of 1 also.

My POST handler uses the same model instance both as an input and as an output. The system creates a StudentReassignmentForm from the POST data, then I change some values, add some others, and use it to render the view for the next step. Is that a supported scenario? I wonder if the problem is related to caching the values of the lambda expressions (which I assume is done for performance). Maybe Html.HiddenFor and Html.EditorFor are picking up a stale cached value.

In any case, I see my workaround, which is just to hard-code the step number in my views.

  • 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-05-23T19:03:20+00:00Added an answer on May 23, 2026 at 7:03 pm

    Please try to use this statement immediately before returning a view in your controller.

    ModelState.Clear();
    

    I believe this should solve your issue.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to

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.