Solved

Uncheck Radio Button in ASP.NET

Posted on 2010-09-17
12
865 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
  • 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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