MVC中的多页向导 - 存储输入数据的位置

时间:2022-05-19 20:07:47

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

您认为在asp.net-mvc中创建多个页面向导的最佳方法是什么?我在想:

  1. create a hidden field in every page which contain my whole object serialized
  2. 在每个包含序列化整个对象的页面中创建一个隐藏字段

  3. override OnActionExecuting -> get my object from the hidden or tempdata
  4. override OnActionExecuting - >从hidden或tempdata中获取我的对象

  5. override OnResultExecuted -> put the object in tempdata, when i go to the next page(when redirect)
  6. override OnResultExecuted - >将对象放入tempdata,当我转到下一页(重定向时)

1 个解决方案

#1


6  

  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'>
  • 在进行下一步时(通过javascript或通过提交表单)

  • Handle the form-post to extract the data inserted by the user
  • 处理表单以提取用户插入的数据

  • Store your previously stored answers in a Session variable, and retrieve the object when in the form-post
  • 将以前存储的答案存储在Session变量中,并在表单中检索对象

  • Add the new answers, and re-save the object in Session
  • 添加新答案,然后在Session中重新保存对象

  • 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.

    其中包含每个向导的属性 - 用于保存用户数据的答案。

    #1


    6  

    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'>
  • 在进行下一步时(通过javascript或通过提交表单)

  • Handle the form-post to extract the data inserted by the user
  • 处理表单以提取用户插入的数据

  • Store your previously stored answers in a Session variable, and retrieve the object when in the form-post
  • 将以前存储的答案存储在Session变量中,并在表单中检索对象

  • Add the new answers, and re-save the object in Session
  • 添加新答案,然后在Session中重新保存对象

  • 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.

    其中包含每个向导的属性 - 用于保存用户数据的答案。