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)

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?


2/13/2009 12:49:24 AM 24353 articles. 1 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 34


Try this code

<html xmlns="">

<head runat="server">

<title>Untitled Page</title>


function check()


for (var i = 0;i < form1.radiolist.length; i++)


if (form1.radiolist[i].checked == true)


"Selected Item Value"+ i);







<form id="form1" name="form1" runat="server">


<asp:RadioButtonList runat="server" ID="radiolist">

<asp:ListItem Value="0" Selected="True"></asp:ListItem>

<asp:ListItem Value="1">item1</asp:ListItem>

<asp:ListItem Value="2">item2</asp:ListItem>

<asp:ListItem Value="3">item3</asp:ListItem>


<input type="button" onclick="check()" value="submit" />






2/13/2009 5:11:24 AM

Use NewAlbumEditorAJAXTypeOption = '<%= RadioButtonList1.ClientID %>' to get the radio button list object and use getElementsBytagName('input') method on that object to get a list of input objects. then iterate through them and check if type=='radio' and object.checked == true. If this condition is satisfied, then u break the loop and get the object u wanted.


Please remember to click "Mark as Answer" on the post that helps you.

All Code is provided AS IS
2/13/2009 9:16:15 AM

Similar Artilces:

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.-...

User Controls not working if I put Validation controls in user control
Hi           I have validation controls(RequiredField Validator,RegularExpressionValidator)  in user controls.User controls are not posting back like the events are not wiring up.If I remove Validation controls in User controls page,user controls are working fine.Can anyone please help me out in getting it fixed. In the Validation controls, make sure you are setting the ControlToValidate property to the control that it links to.  If you're in .NET 2.0, it's also a good idea to put all the validation controls in the same Valid...

Validation for controls that is inside user control
I have a dropdownlist (only control) in the user control. This user control is used inside the formview. What is the best way to validate from the formview wether this contol has a value selected. Thanks Use the RequiredFieldValidator. Set its InitialValue property to the same value you assign to the unselected item's ListItem object. Keep in mind by "Value", there are two data elements on ListItem: Text and Value. Text is shown to the user. Value is internally used and is what you assign to InitialValue.--- Peter BlumCreator of Peter's Data Entry Suite (formerly Profess...

Validation controls inside user controls
Hi, I'm creating a very simple user control to which I also added a validation control. For example: In Assignment.ascx: <asp:DropDownList ID="ddlOrganization" runat="server"></asp:DropDownList><asp:RequiredFieldValidator ID="rfvOrganization" runat="server" ControlToValidate="ddlOrganization" ErrorMessage="L'organisation est requise." Text="*" Display="Dynamic"></asp:RequiredFieldValidator> <asp:TextBox ID="tbxProject" runat="server"></asp:TextBox&...

validating the Controls inside the User control.
Hi,   In my aspx page i have a two butons. 1. Add New  2. Save Every time when  i click the Add New  button i load the user control by multiple user control inside the panel. Then the user control  have some textboxes. i want to validate(using javascript) the textboxes when i click to save button.becoz all the textboxes have different name on runtime. can anyone helpme out this problem.   Thanks. Safiulla     safiulla: In my aspx page i have a two butons. 1. Add New  2. Save Every time wh...

Radio button controls and Validation control
Hi, 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, J 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. Well, they are radiobutto...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in ( required field, range validator and others) question is the required field validator is a server side control. So does that mean that it does a post back? it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Validation Controls Client Script Conflict
I had a web form set up using 2 validation controls, with the client script working just dandy. When a user tabbed out of an empty field that was required or hit the submit button the form was not posted back and a nice label popped up with a helpful message.When I installed atlas in my web application the client side validation functionality stopped working on my form. Regardless of what was in the form fields the form was posted back to the server when the submit button was clicked and nothing at all happens when required fields are tabbed out of when empty.Is it possible I have my...

checking the value of a parent control in a user control
hi, how could i check the value of a textbox in the parent form withing the user control page_load event. The page load event in user control loads on postback and i want to check the value then and then either do stuff there You can expose a property in the user control. And set this property from the parent page.~ Firoz AnsariPune, Indiahttp://www.firozansari.comWhy product testing is important?...

Web User Control +Client Side Control
Two Questions if Possible:  1: Some controls have methods/properties that can be gotten/set client-side (IE ASP:Timer).  Can usally access them by "$find('<%=Control.ClientID%>').get_(set_)name()".  I made a User Control that has a "Enabled" Propertiy (basically sets a bunch of its components to "visible = false" and then a Timer.Enabled=false).  I can't access my user controls "enabled" via client side script (IE $find(UserControl.ClientID).set_enabled(false)).  How do I bundle this type of fu...

Accessing controls inside User control template
Hi, I need to create a user control with one template. That template needs to be like View in MultiView or Wizzard control or Panel. It means, that controls, which are inside should be visible to the page. It will be created just once per control. I need to be able to write :  TextBox1.Text = "Hello world" not : (MyUserControl1.Controls.FindControl("TextBox1") as TextBox).Text = "Hello world" Thanks, radco  If this is a answer to your problem, mark it as answer in right upper corner. It helps other who read your article to known that...

Hello, I've come across the problem when I wanted to use client side validation (no matter of which type) depending on the input from a different control. The scenario is: I have two textboxes A and B. A does not need to be validated (no validator associated with A). The textbox B has to be validated if and only if the A has any value. I know this is trivial with custom validator in the server side mode... But unfortunately I want it to run the validation on the client side. And I also know that I can write a javascript function for the ClientValidationFunction and hardcode client id ...

User Controlers: Changin a string value according to which button is clicked in Header user control
I'm using Visual Studio 2003 and I figured out how to pass strings between usercontrols and the page. But now I have a new problem.There are couple of Buttons in usercontroler which i named as Header1. When each Button is clicked I have  to pass a different string to the main page (ex: string temp changes when button1 is clicked and when button2 is clicked temp changes again). Therefor string depends on which button is clicked. Using my main webform i send this string from Header1 and give it to the second usercontrol Side Menu.  Problem is : How to change the value in that strin...

User Control inside User Control
I have an ASPX with user controls in it called UC1.There is another user control called UC2 within user control UC1.(UC1 - parent , UC2 - child) What I need to do is to pass value of the text box that’s located inside user control UC1 to UC2. This is the code I put into  user control UC1. How to I read it in User control UC2?   Public ReadOnly Property propCountryName() As TextBox Get Return Me.txtCountrygName End Get End Property    Thank you100 years live, 100 years learn You can define a property inside the UC1 and UC2. Pag...

Web resources about - validating the checked value of an radio button in javascript when the control is inside templates and user control??? -

Talking to police about Ghomeshi allegations was validating: Decoutere
One of the women accusing former CBC host Jian Ghomeshi of violent behaviour is encouraging other potential victims not to be afraid of speaking ...

Validating Input and Interprocess Communication
Describes techniques to use and factors to consider to make your code more secure from attack.

Validating team-by-team R and RBI predictions for 2012 NL Edition
As I've explained in the first of these articles , I made a few predictions over at dear, departed fantasy blog RotoHardball during the last ...

"It is important not to create a precedent validating the prohibition of the sale of any object of a ...
"... regardless of the culture concerned... Our goal has always been to showcase Hopi culture and make it accessible to the largest number of ...

Validating the Donald
Validating the Donald by digby In Salon today , I wrote about the right wing media's immigration backlash strategy by validating Donald Trump's ...

Validating your marketing audience
... enjoyed this, please share it with your network! Want to read more like this from Christopher Penn ? Get daily updates now: The post Validating ...

Validating Albert Einstein, physicists make major discovery about the early universe
In the beginning there was the Big Bang. What we know about this time is that the universe was extremely hot, dense and almost uniform; it was ...

Validating Architecture through LINQ Query
... is simple enough to get validated at a glance. But at a glance is not enough. What about defining custom rules that take care of validating ...

From Data to Action – Best Practices for Validating and Optimizing Your Digital Campaigns - comScore ...
In this webinar, comScore Senior Industry Analyst Jason Patterson explores how you can use comScore's validated data to optimize and improve ...

TDD of a WinForm app – Part 5 – Validating the account data
In our last post, we worked on allowing our user to enter new accounts – basically making our AddAccountForm usable. We were able to do that ...

Resources last updated: 12/1/2015 2:53:16 AM