Solved

Uncheck Radio Button in ASP.NET

Posted on 2010-09-17
12
855 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now