ValidationSummary can easly display error messages开发者_StackOverflow.
But how can I make it a success message I return from my action.
I am calling this action within Ajax request.
Any idea?
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);
});
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
精彩评论