I have 2 views both with forms.
I use TempData to pass between views. Which works fine. View2 receives data from View1 through common Model object. The model's data comes from both View1 & View2.
But when View2's form is submitted开发者_运维知识库, the model does not retain View1's data. They are all reset to null & 0.
This is understandable looking at how HTTP works.
But what is the best way to get data from multiple views in a single Model.
Two possibilities to consider:
- Use the Session to store the values from View1 in between form POSTs.
- Place the View1 data in hidden fields on View2. That way it will be retained when View2's form is POSTed.
精彩评论