bogus
bogus

Reputation: 71

Multi-page wizard in MVC - where to store the entered data

What do you think it's the best way to create a wizard over several pages in asp.net-mvc ? I am thinking to:

  1. create a hidden field in every page which contain my whole object serialized
  2. override OnActionExecuting -> get my object from the hidden or tempdata
  3. override OnResultExecuted -> put the object in tempdata, when i go to the next page(when redirect)

Upvotes: 5

Views: 1763

Answers (1)

Jan Jongboom
Jan Jongboom

Reputation: 27323

  1. Wrap each step in the wizard in some <form> element
  2. Do a form submit when going to the next step (either through javascript or via <input type='submit'>
  3. Handle the form-post to extract the data inserted by the user
  4. Store your previously stored answers in a Session variable, and retrieve the object when in the form-post
  5. Add the new answers, and re-save the object in Session
  6. When finishing, retrieve the object, and persist the settings.

Just have some

[Serializable]
public class WizardAnswers

which contains properties for each wizard-answer to save the user's data in.

Upvotes: 6

Related Questions