tags:

views:

91

answers:

2

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?

A: 

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:

<% if (TempData["SuccessMessage"] != null) { %> <%= Html.Encode(TempData["SuccessMessage"])%>
<% } %>

JohnnyO
A: 

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.

DM