0

I am using a dialog box to confirm an action that requires an override by a user's supervisor. When the dialog box pops open the form values are pre-populated with TempData in the view and the text boxes are locked (disabled); except for the text box the supervisor uses. The logic is set to deactivate the lock upon a submit, cancel, or on close event of the dialog box. So the next time the user opens the dialog the text boxes will be enabled and blank for a new submission.

Now, in the event a user refreshes the page (for whatever reason that may be) while the dialog box is opened and in the locked state, the TempData value life cycle ends and when the dialog box is reopened, then the text boxes are in the locked state but empty. So the system is ready to submit a form with a supervisor approval that has empty values.

Now, my question is, on a page refresh, is there some final method that is called to where I can call keep on the TempData? Or what is the best way to retain the TempData only in the event of a page refresh? thanks!

eaglei22
  • 2,589
  • 1
  • 38
  • 53
  • You can look at using `.peek()` or `.keep()`, - [TempData keep() vs peek()](http://stackoverflow.com/questions/21252888/tempdata-keep-vs-peek) - but you really should be saving your data to the database and reading it again. –  Aug 25 '15 at 12:52
  • I am familiar with those, but I really didn't want to kick off the process of moving anything to the database until the requirement of the approver's sign off has been completed. There is a lot of stuff that kicks off on the submit. This is also a pre-written application that I am adding functionality to, so I don't have too much freedom for change without creating much more work due to tightly coupled classes. – eaglei22 Aug 25 '15 at 12:57
  • I was going to use .peek() and then in the controller remove the key from the TempData, but I felt if that was the case then I should probably be using session.. but I was hoping there was a better solution to still use the TempData. Any way, thanks for the reply Stephen. – eaglei22 Aug 25 '15 at 12:59

0 Answers0