Solved

Uncheck Radio Button in ASP.NET

Posted on 2010-09-17
12
876 Views
Last Modified: 2012-05-10
I have Radio Button on my ASP.NET, C# form. Once user clicks on it, user can't uncheck it. Is there any way so that user can uncheck the radio button?
0
Comment
Question by:pawar_deepak
[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
  • 4
  • 2
  • 2
  • +3
12 Comments
 
LVL 5

Expert Comment

by:ploftin
ID: 33706713
I'm not an expert at C#, but try this:
checkboxname.checked = false

Open in new window

0
 
LVL 5

Expert Comment

by:ploftin
ID: 33706715
By the way, checkboxname should be the name the checkbox has on your form...
0
 
LVL 5

Expert Comment

by:ploftin
ID: 33706724
Forgive my C# skills, it's been a long time.  I didn't end my line with a semi-colon, and should have.  
checkboxname.checked = false;

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:ploftin
ID: 33706725
While I said checkboxname above, I actually meant radiobuttonname.  If that doesn't work, try it this way:
document.Form1.radiobuttonname.checked = false;

Open in new window

0
 

Author Comment

by:pawar_deepak
ID: 33706731
Ploftin, thank you for your response but I want solution for Radio Button. You wrote the code for checkbox...
0
 
LVL 21

Expert Comment

by:chapmanjw
ID: 33706767
This solution would help you out.  You have to do it on the JavaScript end.  So you can either push out the JavaScript from your C# code when needed (like with Response.Write).  Or you can put it on your page with a button (like "Reset Selection") that runs the JavaScript function.

This post should help you out: http://forums.asp.net/p/1291117/2503921.aspx
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33706777
What are the options for your radio buttons? Why dont you add another one which basically is NO SELECTION type

eg radio buttons say Yes, No to a question. Add another one say Unsure

so clicking Yes then clicking Unsure is like unchecking Yes
0
 
LVL 20

Expert Comment

by:informaniac
ID: 33707071
<asp:RadioButton ID="Btn1" runat="server" onclick="javascript:return Checked(this);" />
   
    <script type="text/javascript" language="javascript">
        function Checked(obj) {
            obj.disabled = true;
        }
    </script>
0
 
LVL 20

Expert Comment

by:informaniac
ID: 33707080
Oh sorry I absolutely misunderstood ur question...
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33707102
0
 
LVL 16

Accepted Solution

by:
Vikram Singh Saini earned 500 total points
ID: 33710215
Hi,

It  seems to me that you are trying to use radio buttons in a way they  were not designed to be used. You cannot uncheck a radiobutton unless you have multiple radiobuttons  of the same group.

<asp:RadioButton ID="RadioButton1" runat="server" GroupName = "First" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName = "First" />
<asp:RadioButton ID="RadioButton3" runat="server" GroupName = "First" />

Else if you have only one radiobutton use a checkbox instead.

Regards,
VSS
--------------------------------------------------------------------------------------
Reference: http://forums.asp.net/t/1438501.aspx
--------------------------------------------------------------------------------------
0
 

Author Closing Comment

by:pawar_deepak
ID: 33719962
I used Checkbox instead of RadioButton as suggested.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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