Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Validating multiple radio buttons with custom validator control

Posted on 2012-04-02
2
Medium Priority
?
481 Views
Last Modified: 2012-06-22
Hi,

I have three sets of radio button in 3 different groupID on my aspx page. If I have to do a validation so users have to select at least one from each group how do I achieve this.

Say this is what I'm doing:

 private void ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (rdbLeveltwo.Checked == false && rdbLevelthree.Checked == false
               && rdbLevel23.Checked == false && rdbLevelfour.Checked == false && rdbLevel34.Checked == false)
     {
         args.IsValid = false;
     }
     else
     {
         args.IsValid = true;
     }
 }

This will validate one group and I can give the error message specific to this group that's fine. However, how do I handle the next two group and most importantly error messages specific to those group as I have set this error message already specific to the group1.

Please someone advice me!

Thanks in advance!
0
Comment
Question by:ube100
2 Comments
 
LVL 21

Accepted Solution

by:
masterpass earned 2000 total points
ID: 37798722
option 1

Use a radiobuttonlist with a required field validator
eg: http://asp-net-example.blogspot.co.nz/2009/02/aspnet-requiredfieldvalidator-example.html

option 2

have 3 customvalidators for three groups of radiobuttons. This way you can have three distinct message for each group

Hope this helps!
0
 
LVL 7

Expert Comment

by:dhawalseth
ID: 37801340
i believe you can use jquery for your need. better option.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

810 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