views:

38

answers:

2

ValidationSummary can easly display error messages.

But how can I make it a success message I return from my action.

I am calling this action within Ajax request.

Any idea?

+2  A: 

As you've discovered ValidationSummary is for displaying error messages. If you are using AJAX you could have your action return messages in JSON:

[HttpPost]
public ActionResult Foo()
{
     // Do something
     return Json(new { message = "success" });
}

And then call it:

$.post('/home/foo', { }, function(json) {
    alert(json.message);
});
Darin Dimitrov
A: 

Ideally, I want to do something like this

ModelState.AddModelError("SUCCESS", mySuccessMessage);

I'm thinking about modifing the CSS of ValidationSummary to display the message in green color.

but I don't know where this CSS is located