ASP.NET MVC: How to pass data between incomplete f

2019-04-15 06:13发布

In my Asp.net MVC project, I have a scenerio where in,

  1. User have a big form named "Form A" to fill up.
  2. On filling half of the Form A,user is redirected to Form B to fill information.
  3. On completing Form B, user is redirected back to Form A and at this time Form A should be pre-filled by the information user filled before going to Form B.

How and where to hold the half filled Form A information when user is filling Form B and how to refill Form A with this previously filled information?

2条回答
Evening l夕情丶
2楼-- · 2019-04-15 06:18

One approach would be to save the incomplete object/form that you are building (you may consider forms A,B,C, etc... as parts of a wizard) to the database and just pass the id to the next step of the wizard. This also means you need to make some of the database fields nullable, but it has BIG advantage that you can also save the id in a cookie and allow the user to come back to the wizard at some later stage. This approach does not require any javascript or session state.

For a sample code samples on asp.net wizards you make look the following posts:

1) Create a Wizard in ASP.NET MVC 3

2) Creating a simple form wizard in ASP.NET MVC 4

3) Creating Wizard in ASP.NET MVC Part 2

查看更多
beautiful°
3楼-- · 2019-04-15 06:31

is this helpful Passing Data in an ASP.NET MVC Application

You can store values in ViewData or in Session to pass values while navigating from Page A to Page B

For Big Data entry Pages - as suggested in comment- Best choice is to store data into Database. as it will be quite annoying for user to fill up data agian in any case.

查看更多
登录 后发表回答