Reputation: 28248
What patterns are people using to display status messages and error messages to users in Asp.Net MVC?
I currently use ModelState.AddModelError for problems with adding / editing / updating objects but what about after that? Say a status message's to let them know their action ran correctly?
Was thinking about using TempData since alot of times a re-direct is involved.
Anyone have a good pattern they are using that works well?
Upvotes: 2
Views: 1274
Reputation: 1847
I've been using the built in Html helpers (Html.ValidationSummary(), Html.ValidationMessage()) along with xVal to display all validation messages. I then use TempData to display all other status messages to the user.
Upvotes: 0
Reputation: 57482
I use ModelState.AddModelError for error messages and TempData for success messages. I have the following code on my master page so that any time TempData["SucessMessage"] is defined, the success message will be displayed to the user on top of the page:
Upvotes: 3