Radio button controls and Validation control


I have a group of radio button controls. I want to force user to selecte one those. If not, show a message. I tried to use a RequiredFieldValidator, but ControlToValidate shows nothing.

I can check each radio button and check if any is selected, but am sure there is a smarter way. Maybe using a validator. Would you let me know?

Thank you,


7/27/2007 1:34:44 PM 93655 articles. 6 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 57

required field validator validates some inputs like date, integer, string .

 you cannot validate the checkbox using a requiredfield validator.

Got what you needed. Please mark as answer.
7/27/2007 1:47:19 PM

Well, they are radiobuttons, not checkboxes. But I understand what you meant. Thank you for the help.

Then is there any way to force the user to select one of options like a validator?


7/27/2007 3:43:30 PM

<asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID="AccessDataSource1"

DataTextField="CategoryName" DataValueField="CategoryID" ValidationGroup="grp">


<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadioButtonList1"

ErrorMessage="RequiredFieldValidator" ValidationGroup="grp"></asp:RequiredFieldValidator>

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb"

SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:AccessDataSource>

<br />

<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="grp" /></div>
7/27/2007 4:14:02 PM

A clarification of the last post. The RadioButtonList can be validated by the RequiredFieldValidator. Individual radiobuttons cannot. You need to use a CustomValidator and create your own evaluation code to test the state of each checkbox.

My Professional Validation And More's MultiConditionValidator can be used to handle this case too. Here's an example:

<vam:MultiConditionValidator id="RequireRadios" runat="server" Operator="OR" ErrorMessage="Select one" >
   <vam:CheckStateCondition ControlIDToEvaluate="RadioButton1" />
   <vam:CheckStateCondition ControlIDToEvaluate="RadioButton2" />
   <vam:CheckStateCondition ControlIDToEvaluate="RadioButton3" />

--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
7/28/2007 5:02:40 PM

Similar Artilces:

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

Validation controls are triggereing other forms validation controls?
Can someone please look at this an explain whats going on. When you click on subscribe it triggers my registration form validation controls. I'not sure what "subscribe" is supposed to do, but if you dont want it to cause validation, set the CausesValidation property to false.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: Make sure the feild is an email address Hey coolkidsonly, your initial posting didn't show us anything to look at. We are just guessing here without the specifics. However, m...

How to validate controls on a .NET 2.0 Web user Control
Hi Guys, (ASP.NET 2.0 / C#) I've looked thorugh every post on validating web user controls (and know about Pter Blum's Professional Validation and More package) - but can't seem to get my head around whre to start. I have a web user control, called wucICL.ascx on a we page called AddEditInvestment.aspx.  I would like to validate a couple of DropDownLists (ddlAccounts and ddlContacts) when the Insert and Update buttons are clicked on the AddEdit Investment page. The other controls on the AddEditInvestments page belong to a validation group called All Validators and the DropDownL...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

validating the checked value of an radio button in javascript when the control is inside templates and user control???
I nee to know which radio button is selected on the client using javascript with this code it seems is how it is done: for (i=0;i<document.test.myradio.length;i++){if (document.test.myradio[i].checked==true)theone=i but my radio is a radiobuttonlist inside a usercontrol on a contentpage and all I can get to is the clientID like this: var NewAlbumEditorAJAXTypeOption = '<%= RadioButtonList1.ClientID %>' but how will I find my control and iterate thru the options?   Hi Try this code<html xmlns=""> <head runat=...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

Controlling the controls a validator validates
Hello, I want to control which controls appear for a validator when they go to controltovalidate dropdown in property grid.  Is the solution to create a designer for the control?  How do you regulate that?  I can't override the ControlToValidate property... Thanks.Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). Well ur logic is true, thats the way, what u need to do is not override the property (cant), create another property, that implemen...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

controlling an object in a web control from the page the web control is placed in
I have created a web control in that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

validate Textbox in Web User Control from web form?
ASP.NET 2.0 I have a web user control that contains a textbox.  I need to add some validation (like requiredfieldvalidator, comparevalidator, etc). I would normally add the validator to my web user control by placing the validator next to my textbox.  However, I need the validation message somewhere else on my web form, not near the user control. So how would I associate a validation control on my web form with the text box inside my web user control?  Can this be done; any alternatives out there? Thanks!   The error message should occur wherever you place the vali...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Creating a User Control validator that validates a control on the page, rather than inside the control.
I'm trying to create a custom user control that is nothing more than a RangeValidator that validates other controls that lie on the page rather than inside the control itself... is this possible, is there a way to "bubble" it up. Thanks, G My answer to your other question regarding the CompareValidator applies here. If the custom control is in the same naming container AND does not implement INamingContainer, you can create a property that lets the user assign the control to validate. Internally assign the Validator.ControlToValidate property to the value of that property.-...

I have a wizard with a few steps. One of the steps contains a web user control with 3 text boxes. I'd like to validate that these text boxes have data before allowing the user to go to the next step. I tried putting the requiredvalidators inside the web user control - but these arent fired when the Next button is clicked. I tried putting the requiredvalidators on the Step page itself but cant wire them up to the web user control. Whats the correct way to do this ? Hi, Would you please post the code of the ASP.NET? I will be waiting for your feedback. Hong GangHong-Gang ChenMicroso...

Web form Controls vs HTML controls
Hi, can anyone explain me the difference between Web Form Controls and HTML controls? What is their usability and disadvantages? Can i write code behind HTML controls?    Thanx in advance. Yes, you just have add "runat=server", in your HTML control. The Web Server Control, have more funtionality that the HTML controls. With Web Server Control, you can work easy with Data. Too, you have controls as AdRotator, WebCalendar and more... : Sergio Tarrillo Here are the Recommendations from Microsoft ....when to use 1 over the other...

Web resources about - Radio button controls and Validation control -

Validation (drug manufacture) - Wikipedia, the free encyclopedia
In the pharmaceutical , medical device , food, blood establishments, tissue establishments, and clinical trials industries, validation is the ...

Serena Williams eyes history, Caroline Wozniacki craves validation in women's US Open final
As Serena Williams eyes another slice of tennis history, Caroline Wozniacki is craving validation with a watershed US Open final triumph on Sunday ...

Travers Duncan asks High Court to strike down ICAC validation laws
ICAC could be sent back to the High Court as a challenge to new laws validating corruption findings looms.

Adam Scott proclaims Texas win as validation of No.1 ranking
... No.1 golfer, beating American Jason Dufner in the third hole of a play-off at the Colonial event. "It's a good feeling and maybe some validation ...

Hollande to sign gay marriage bill after Constitutional Council's validation
Hollande to sign gay marriage bill after Constitutional Council's validation People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, ...

Marketers, Get Ready for the 'Validation Era'
The public brands included has been engaging in a "friends" arms race. But there are signs that we know we overdid it.

Validation and Uncertainty
What an extraordinary conversation I had recently on Twitter. It started with Neil Killick’s statement that we should not consider our stories ...

Nvidia Icera 410 LTE Modem Passes AT&T Network Validation
... Today's news is a small step and logical precursor toward both goals, Nvidia's Icera 410 LTE and HSPA+ baseband has passed AT&T's network validation ...

Ting’s Q1 Subscriber Growth Suffers from Sprint’s New Unlocking Validation Process
Back in February, Sprint updated the process it uses to validate unlocked devices that customers want to utilize on other carriers or one of ...

[Android M Feature Spotlight] Stricter APK Validation Now Actually Checks If All Of An APK's Files Are ...
While you might file this one under "really? We weren't doing this already?" if you're a security expert, Google has added stricter validation ...

Resources last updated: 1/3/2016 1:48:06 PM