开发者

ModelState.AddModelError showing error twice

With MVC stuff when there is an error on property level, we can add error to Mod开发者_JS百科elState but the same error is added to the summary also. How can we avoid to display it twice.

I want to display only public errors in the message summary and all other at property level.

Regards Parminder


When defining your validation summary set the first parameter to true which means Exclude Property Errors.

Eg:

<%= Html.ValidationSummary(true, "Unable to save item. Please correct the errors and try again.")%>

From MSDN:

excludePropertyErrors Type: System.Boolean

true to have the summary display model-level errors only, or false to have the summary display all errors.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜