Sander
terug naar het overzicht

Hidden Validator…

door Sander 20-7-2011

Working on some large complex ASP.NET thing and have a client-side validator blocking a postback but you cant see which one because it is invisible? Check… The validator that was blocking the postback was not visible, but was still enabled. 

 

Page.IsValid will obviously say false when a postback occurs and a validator is tripped. In my case the validator tripped without me knowing about it. You could call that PEBCAK but it had to be solved. Since I didn’t want to spend to much time finding the annoying validator I used trusty old LINQ to find it for me.

 

At the point Page.IsValid is checked, I wrote this line and slapped a breakpoint on it:

var annoyingValidator = Page.Validators.OfType<IValidator>().Where(v => !v.IsValid);

From there I could see the errormessages of the validators that were being tripped, Ctrl + F and hey presto. Added some code to make sure the validator is disabled at the right time and problem solved.

Tags:

Reactie plaatsen


(Zal uw Gravatar icon tonen)

  Country flag


  • Reactie
  • Live voorbeeld