开发者

How to return an error to ValidationSummry in MVC 3

开发者 https://www.devze.com 2023-03-14 01:52 出处:网络
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

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

精彩评论

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