Solved

asp.net radio button

Posted on 2014-07-18
4
389 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 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 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 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