开发者

How to return an error to ValidationSummry in MVC 3

I have an idea which I dont know how to implement. In MVC 3 controller I have an if statement, and I want t开发者_开发百科he controller to return an error message if the if statement fails. And I have a ValidationSummery on that page, so its better if it will catch the error message and present it..

How do I do this?

Thanks


In the controller you can add an error message by

ModelState.AddModelError(string key, string errorMessage);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜