Solved

Validating multiple radio buttons with custom validator control

Posted on 2012-04-02
2
467 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 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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