Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-06-21
6
Medium Priority
?
300 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 64

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 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