Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / September 2005

Tip: Looking for answers? Try searching our database.

CausesValidation not working as expected.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris McKenzie - 27 Sep 2005 20:37 GMT
This is a hairy one.

I have a situation in which the textbox.validating event fires when it
should not. The Text box is itself contained in a user control, which is
then loaded dynamically into a panel on a form. The form has some buttons on
it, some of which have CausesValidation set to True, and some of which have
CausesValidation set to false. The buttons themselves are on the form, not
inside the user control The User Control contains a required field validator
extender control as in the book "Developing Microsft .NET Controls with
Microsoft Visual Basic .NET." The Extender simply captures the Validating
event from the textbox and returns true if there is text in the box, and
false otherwise.

Given the way I have the control set up, the Validating Event for the
textbox should not be firing when I click a button with
CausesValidation=False. In fact, the Validating Event does NOT fire in this
scenario IF THE CONTROLS ARE ALL DIRECTLY ON THE FORM ITSELF. It's only in
this situation where the validation occurs inside the User Control that it's
an issue.

Any thoughts on what might be causing this?

Example:

TextBox contained in Form,  Button contained in Form with
CausesValidation=False, TextBox.validating Event does not fire

Textbox contained in UserControl, Button contained in Form with
CausesValidation = False, TextBox.Validating Event does fire.

Thanks,
Chris McKenzie
Chris McKenzie - 27 Sep 2005 21:25 GMT
Okay, nevermind. I found the issue. The problem was that the button in the
latter case was itself contained in a panel, and the PANEL had
CausesValidation=True.  Argh!

> This is a hairy one.
>
[quoted text clipped - 28 lines]
> Thanks,
> Chris McKenzie

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.