• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 913
  • Last Modified:

Uncheck Radio Button in ASP.NET

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
pawar_deepak
Asked:
pawar_deepak
  • 4
  • 2
  • 2
  • +3
1 Solution
 
ploftinCommented:
I'm not an expert at C#, but try this:
checkboxname.checked = false

Open in new window

0
 
ploftinCommented:
By the way, checkboxname should be the name the checkbox has on your form...
0
 
ploftinCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ploftinCommented:
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
 
pawar_deepakAuthor Commented:
Ploftin, thank you for your response but I want solution for Radio Button. You wrote the code for checkbox...
0
 
chapmanjwCommented:
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
 
rockiroadsCommented:
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
 
informaniacCommented:
<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
 
informaniacCommented:
Oh sorry I absolutely misunderstood ur question...
0
 
rockiroadsCommented:
0
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
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
 
pawar_deepakAuthor Commented:
I used Checkbox instead of RadioButton as suggested.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now