Solved

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

Posted on 2013-06-21
6
296 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 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