I've been searching for this topic on SO and it's quite a headache not finding one.
I had developed a website for some time already and found that the current problem is that after postback, if the submission has any error and the user is redirect back to the form, the form values are all gone.
Is there a good way/flow/design to implement such that after postback the values are retained? Also I need to consider default values, values from database and the values from postback - so which one takes priority?
In addition, I wish to follow Post-Redirect-Get and use back the same form.
What I had thought of was:
- Identify each form with a unique ID
- When submitted, save all data into the Session using the form's unique ID
- When the form is requested again, show the values from the form.
- If submitted successfully, clear the data in session.