Solved

Uncheck Radio Button in ASP.NET

Posted on 2010-09-17
12
870 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
Google Directions API to Map URL -C#? 3 38
HTML - Color not displaying correctly in EMAIL. 6 49
TimeZone, day light savings, Sql server, asp.net 6 38
abstract class C# 1 31
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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

830 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