Solved

How can I determine if a radio button is clicked during a MaskedTextBox validated event?

Posted on 2013-06-21
6
298 Views
Last Modified: 2013-07-22
I have two radio buttons, ID One and ID Two.  I have two MaskedTextBoxes, ID One and ID Two.  The user can choose to enter an ID for either one of the MaskedTextBoxes.  These are two different types of IDs.  Each can be used to enter a person's ID to pull a record.  Some users will want to use ID One type and some users will want to use ID Two type.  During the respective MaskedTextBox's Validated event, the app searches for the entered ID and, if valid, populates the other fields on the screen accordingly.  If a user selects ID One radio button, the form clears, the ID One Masked Text Box is enabled and becomes the active control; and, the ID Two MaskedTextBox is disabled.  If a user selects ID Two radio button, the form clears, and the reverse occurs.  Here's the problem:

When a radio button is selected (while active control is the enabled MaskedTextBox), the Validate event of the current active control fires.  At this point, I really don't want to validate the active MaskedTextBox, as I am just clearing and trying to reset the form and change to enable the other MaskedTextBox.  I tried to used the radiobutton's Checked property, but, at this point in the process, the status hasn't changed yet.  It does not change until some time after the Validated event is finished.

How do I control the Validated event to only execute code when the Validated event is NOT triggered by changing the radio button selection?
0
Comment
Question by:spazjr01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39266776
You can check the property Checked to see if it is checked or not. See the documentation [here]
0
 

Author Comment

by:spazjr01
ID: 39266788
As I stated in the original problem, this does not work.  Please see second paragraph of original problem.
0
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 39266891
What happens when you set the CausesValidation property on the radio button to false?

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkbox.causesvalidation(v=vs.100).aspx
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:spazjr01
ID: 39266928
Unfortunately, the CausesValidation approach does not work either.  Just tried it.  Though property is set to false, the validated event still fires.  I read the info in the link.  This is for validating a web page.  Unfortunately, I'm not working on a web app.  This is a windows stand alone console app.  So, this approach does not appear to be for other controls on the form of a windows app form.
0
 

Accepted Solution

by:
spazjr01 earned 0 total points
ID: 39334754
To solve this I removed the Validation event and added an OK button, which the user clicks when ready to submit the ID.  I moved all validation code to the OK click event in order to control when it validates.  So, I had to work around this issue, because I couldn't find a solution stop the validation.
0
 

Author Closing Comment

by:spazjr01
ID: 39345494
Nobody provided a working solution, so I came up with my own work around.
0

Featured Post

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question