Solved

Validating multiple radio buttons with custom validator control

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

13 Experts available now in Live!

Get 1:1 Help Now