C# UserControl Validation
Posted
by Barry
on Stack Overflow
See other posts from Stack Overflow
or by Barry
Published on 2010-04-26T07:00:18Z
Indexed on
2010/04/26
7:03 UTC
Read the original article
Hit count: 489
Hi,
I have a UserControl with a Tab Control containing three tabs. Within the tabs are multiple controls - Datetimepickers, textboxes, comboboxes.
There is also a Save button which when clicked, calls this.ValidateChildren(ValidationConstraints.Enabled)
Now, I click save and a geniune validation error occurs. I correct the error and then click save again - valdiation errors occur on comboboxes on a different tab. If I navigate to this tab and click save, everything works fine. How can this be? I haven't changed any values in the comboboxes so how can the fail validation then pass validation?
The comboboxes are bound to a dataset with their selectedValue and Text set. I just don't understand what is happening here.
This behaviour also occurs for some textboxes too. The validation rule is that they have to be a decimal - the default value is zero, which is allowed. The same thing happens, they fail validation the first time - I make no changes, click save again and they pass validation.
If you need any further information please let me know
thanks
Barry
© Stack Overflow or respective owner