Solved

asp.net radio button

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Title # Comments Views Activity
Triple line in an alert message 4 19
Two decimal 5 25
WordPress Page Content Lost 2 14
Check input text, Number 6 27
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

740 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