ModelState.IsValid is false prior to validation

随声附和 提交于 2019-12-02 11:24:18
Jeremy Armstrong

This issue is not related to IoC model binding. MVC has an issue of still rendering an empty container for your validation summary, even if you have no validation errors. Two possible work arounds include:

  1. Create a partial that wraps the validation summary. In that partial, check for any errors in your model state before rendering the validation summary. Use that partial in place of where you would have used the stand alone validation summary.
  2. Add some CSS that hides the containing div if it does not contain any populated or visible list items. If there are no visible error list items, the container's display should be none.

See this for additional info: Related Question

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!