Steve Sanderson BeginCollectionItem does not work in all cases ... a potential solution?

1 answer

What to consider:

  • Data annotations will not be displayed unless FormContext exists in any method that you use to create this optional object. If you are using a partial view, add the following to it:

-

  if (this.ViewContext.FormContext == null) { this.ViewContext.FormContext = new FormContext(); } 
  • If you dynamically add an element to the page via AJAX, after adding a new element, you should clear the validation data in the DOM and reanalyze all your validation elements, for example:

-

  $("form").removeData("validator"); $("form").removeData("unobtrusiveValidation"); $.validator.unobtrusive.parse("form"); 
+21
source

All Articles