?
Solved

Validating multiple radio buttons with custom validator control

Posted on 2012-04-02
2
Medium Priority
?
479 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
[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
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

649 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