Solved

asp.net radio button

Posted on 2014-07-18
4
373 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
  • 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 33

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 500 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 33

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

759 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

20 Experts available now in Live!

Get 1:1 Help Now