Nested Razor layouts causing client validation to fail

 ̄綄美尐妖づ 提交于 2019-12-04 19:07:57

try this for starters: In each view at the top you need to make sure you have a form context available -

@{
if(ViewContext.FormContext == null) {ViewContext.FormContext = new FormContext();
}

I actually put this in my _ViewStart.cshtml because ajax loaded views will require this for validation to work properly at times (plus some other code) - but give it a try for your issue

I believe your issue is if a view does not have a Ajax.BeginForm or an Html.BeginForm in the view itself - then the helpers will not emit the data-val attributes.

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