How do you determine which validator failed?

Robert picture Robert · Aug 1, 2011 · Viewed 16.7k times · Source

I am working with a page and I am getting an Page.IsValid = false and I am trying to determine which control is causing the validation problem.

Answer

Ozziereturnz picture Ozziereturnz · Jun 4, 2014

Credit to Steven for this answer, but I had to make some changes for it to work as this.Validators.Where() had some problems.

using System.Linq;

List<IValidator> errored = this.Validators.Cast<IValidator>().Where(v => !v.IsValid).ToList();