Click here to Skip to main content
14,975,411 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi all,

I was building a system where I was using a lot of validation after inserting data in textBoxes but suddenly I found that all validation of all textBoxes in all forms in my system are not firing ,
I tried to trace the validation codes but the trace never reach the validating events.

When I tried to open a new project and test the validation of a textBox ,it was running great.

I tried to recreate new controls , to restart visual studio and restart my windows but the same problem faced me. Theonly solution I found is to copy the validation code to the event TextBox_Leave.
Is there any other choices , can anyone tell me why this problem faced me ?
What should I do to let the validating event fire ?
Should I replace it with the Leave event handler ?
Is this problem from the visual studio ?

Thanks in advance,
:)
Posted
Updated 5-Aug-11 21:54pm
v7
Comments
[no name] 28-Jul-11 8:02am
   
What version of VS are you using? Some version had/have some quirks.
Michael Waguih 28-Jul-11 8:38am
   
VS 2008
parmar_punit 28-Jul-11 10:29am
   
Did you check that the method is properly wrapped with the event or not?
Michael Waguih 28-Jul-11 10:40am
   
yes I do.
and I also try to create a new one with a new event.
This problem has occured to all the forms in my system and I don't find the cause.

The Validating event is raised only when the control that receives the focus has the CausesValidation property set to true. For example, if you have written code in TextBox1's Validating event, and you click the OK button (CausesValidation = true) then the Validating event is raised, but if you click the Cancel button (CausesValidation = false) then the Validating event is not raised.
   
Comments
Michael Waguih 28-Jul-11 10:37am
   
Thank you , I know this and the next control's CausesValidation property is set as true.
but all the system textboxes suddenly stop firing validating.
Before it was working fine.
[no name] 28-Jul-11 10:44am
   
You can use 'this.ValidateChilren()' before saving your data, that will raise the 'validating' event.
Michael Waguih 6-Aug-11 3:41am
   
Thanks for your answer but I need to run the validation when leaving the textBox.
Is there any otherway to run the default way of validation or I use the event Leave ?
You can you causesValidation and validationgroup properties.
   
Comments
Michael Waguih 6-Aug-11 5:54am
   
I checked it and it was properly assigned.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900