Solved

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

Posted on 2013-06-21
6
289 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 62

Expert Comment

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

Author Comment

by:spazjr01
Comment Utility
As I stated in the original problem, this does not work.  Please see second paragraph of original problem.
0
 
LVL 19

Expert Comment

by:Daniel Van Der Werken
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:spazjr01
Comment Utility
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
Comment Utility
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
Comment Utility
Nobody provided a working solution, so I came up with my own work around.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now