Click here to Skip to main content
15,899,124 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
I would like to be able to check/select a radiobutton and then uncheck/deselect(if they select the wrong filed by chance) . Is there a way to do this in asp.net?
Posted
Updated 30-Jul-22 7:42am
v4

I will suggest you to use Checkbox control where you can actually do what you have asked.
But radio button is only that you want to use refer following code :

C#
bool blnState;

public Form1()
{
    InitializeComponent();
}

private void radioButton1_MouseDown(object sender, MouseEventArgs e)
{
    blnState = radioButton1.Checked;
}

private void radioButton1_MouseUp(object sender, MouseEventArgs e)
{
    radioButton1.Checked = !blnState;
}


where radioButton1 is the name of the radio button that you are using.
I have used the mousedown and mouseup events of this control.
 
Share this answer
 
Comments
sam, atlanta 31-Jan-11 13:08pm    
It worked correctly pravin...
Pravin Patil, Mumbai 1-Feb-11 1:19am    
congrats sam
Are you talking about OnCheckedChanged event[^]

As said by Vinoth you need to set autopostback property to true.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900