Reputation: 9911
I am building a form in Net framework 4.0 using linq to sql , and had a question about object persistence.
I have a case where a user is asked to fill out a very long form several pages in length. Since it is so long, there is a need to SAVE the data midstream.
Session level persistence is not an option, since they could SAVE the form midstream, turn off their browser, and retrieve the form partially filled later.
The form fields are mapped to a DB table, with each form being a DB row, however, several fields are required, and are set in the DB as NOT nullable. I want to provide the ability to save the data values incompletely.
What would be the best approach for saving the object midstream in it's incomplete state, then, later when the user SUBMITS the form, submitting the validated and complete object.
NHibernate is also not an option.
Any good ideas appreciated.
Upvotes: 0
Views: 520
Reputation: 52665
It seems to me that you need to answer several questions.
I would definitely consider serializing the data on Session End and storing it in a database. When the users return you can look for it and ask if them if they want to resume or not. This takes care of all of the above except for #5. Whenever you change the object model it does however create a potential for compatibility issues with your serialized data.
Another option I might go with is ask all the required data early and then you can save whenever you want.
Another option is to simply relax the NOT nullable rules and then again you can save whenever you want.
Upvotes: 1
Reputation: 19479
Upvotes: 0
Reputation: 1087
Since you want people to be able to continue filling in the form where they left off, even if they leave the site or restart their browser, saving the partially completed form in the ViewState or Session objects is out.
I think the two ideas that would be the simplest to implement would be to either store all the partially completed values in browser cookies. Or even better (if you have any control of the database) to create a new table in the db with nearly identical fields to the form table. Save the values entered in the partially completed form in that table (call it Form_Incomplete or something), then only insert into your form table once the user does the final save upon completion of the final page.
Upvotes: 0