How to trace which hidden control's validator is failing?
-
Hi, I have a huge page with around 10 custom controls which are shown/hidden depending on what the user chooses in certain drop-down lists. (Please don't ask why the design is like this). Now each of these controls have ASP.Net validators such as
RequiredFieldValidator
,CompareValidator
, etc. Now I'm having a problem of tracing which validator failed if the parent control is hidden in the page (Visible = false;
). Is there an easy way to test this? The only way I can think of is to change the code temporarily and show all the controls all the time just to actually see which one has the problem. But maybe there's a better way. Thanks in advance. RaffertyRafferty
-
Hi, I have a huge page with around 10 custom controls which are shown/hidden depending on what the user chooses in certain drop-down lists. (Please don't ask why the design is like this). Now each of these controls have ASP.Net validators such as
RequiredFieldValidator
,CompareValidator
, etc. Now I'm having a problem of tracing which validator failed if the parent control is hidden in the page (Visible = false;
). Is there an easy way to test this? The only way I can think of is to change the code temporarily and show all the controls all the time just to actually see which one has the problem. But maybe there's a better way. Thanks in advance. RaffertyRafferty
You can have better approach on this. You can create several validation group based on the dropdownlist value. And validate only the groups that are visible. So the validators in different group, would not be fired. Another way, you can enable and disable the validators based on the dropdown selection, as you must be what all validators you need to fire , according to dropdown value. You can have a look one of my article on ASP.NET validators. Exploring ASP.NET Validators
Cheers!! Brij Visit my Blog: http://brijbhushan.net
Check my latest Article :ViewState - Various ways to reduce performance overhead -
You can have better approach on this. You can create several validation group based on the dropdownlist value. And validate only the groups that are visible. So the validators in different group, would not be fired. Another way, you can enable and disable the validators based on the dropdown selection, as you must be what all validators you need to fire , according to dropdown value. You can have a look one of my article on ASP.NET validators. Exploring ASP.NET Validators
Cheers!! Brij Visit my Blog: http://brijbhushan.net
Check my latest Article :ViewState - Various ways to reduce performance overheadHi Brij! Thanks for the reply. That's a good idea... I think I'll do that for the newer pages. However, I don't have the budget to change the validation group of this page that we're tracing. Do you know of a quick (maybe dirty) way of tracing and knowing which validation control is failing? Thanks again.
Rafferty