Solved

asp.net radio button

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

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
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 …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

737 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