?
Solved

asp.net radio button

Posted on 2014-07-18
4
Medium Priority
?
400 Views
Last Modified: 2014-07-18
I have built a 4-option radio button group:
        <asp:Panel ID="Panel3" Class="Panel3" runat="server" >&nbsp
             <asp:RadioButton  name="location" Text="SA" runat="server" style="font-family: Arial; font-size: small" />&nbsp
            <asp:RadioButton name="location" Text="Med Ctr" runat="server" style="font-family: Arial; font-size: small" />&nbsp&nbsp
            <asp:RadioButton name="location" Text="MOB" runat="server" style="font-family: Arial; font-size: small" />&nbsp&nbsp
            <asp:RadioButton name="location" Text="RA" runat="server" style="font-family: Arial; font-size: small" />&nbsp
            
        </asp:Panel>

Open in new window


Question: Why selecting one option doesn't uncheck the previousely selected option?

Thank you.
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40204044
Because you need to give each one the same GroupName attribute in order for them to act as a group:
<asp:Panel ID="Panel3" Class="Panel3" runat="server" >&nbsp
             <asp:RadioButton  name="location" Text="SA" runat="server" style="font-family: Arial; font-size: small"  GroupName="Location" />&nbsp
            <asp:RadioButton name="location" Text="Med Ctr" runat="server" style="font-family: Arial; font-size: small" GroupName="Location" />&nbsp&nbsp
            <asp:RadioButton name="location" Text="MOB" runat="server" style="font-family: Arial; font-size: small" GroupName="Location" />&nbsp&nbsp
            <asp:RadioButton name="location" Text="RA" runat="server" style="font-family: Arial; font-size: small"  GroupName="Location" />&nbsp
        </asp:Panel>

Open in new window

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40204063
Thank you. Works great.

I wonder if you could help me also with

making this group disable and option Text="Med Ctr" selected.

Later on they may all be active.

Regards,

Mike
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 40204171
To manipulate the radiobutton in code you need to give it an ID:
<asp:RadioButton name="location" Text="Med Ctr" runat="server" style="font-family: Arial; font-size: small" GroupName="Location" ID="MedRadio" />

Open in new window

You can then select it through code:
MedRadio.Checked = true;

Open in new window

To disable all of the radio buttons you simply need to disable the panel which houses them:
Panel3.Enabled = false;

Open in new window

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40204192
How about selecting one of the options, for example:

selecting option Text="Med Ctr" selected.

Thanks.

Mike
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

764 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