Solved

Radio Button in User Control

Posted on 2010-09-08
4
651 Views
Last Modified: 2012-05-10
Hi..
I have user control that has a single radio button.  My page loads the control(s) but depending on the data and loads more than 1 of the same control.. up to 5.  My problem is that after the controls are loaded the radio buttons are not in 'synch'  - I can select multiple values - I need to controls to act like 1 single radio group so only 1 button of the controls can be selected.
Any ideas
thanks

0
Comment
Question by:JElster
  • 2
  • 2
4 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 33625734
Giving all the radio buttons the same name attribute should group them.
0
 
LVL 1

Author Comment

by:JElster
ID: 33625805
I tried that - I thought it should work too...

    <asp:RadioButton ID="radDEFAULTADDRESS" runat="server" ForeColor="Black" Name="grpAddress" Text="Default Address" TabIndex="-1" />
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 33626106
Actually it shoud be GroupName="grpAddress", but it still does not work because each radio button group name is prefixed with an id, and the id will always be unique. Even if you do not assign a group name, one is automatically rendered for each radio button added via the same user control.

One possibility is to use a standard html input radio button with a group name in the user control. Then upon submit, use javascript to determine which one is checked.
0
 
LVL 1

Author Comment

by:JElster
ID: 33626181
I found this.. which I think does it....

http://www.codeproject.com/KB/webforms/How_group_RButtons.aspx
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 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