选中并取消选中RadioButton [英] check and uncheck RadioButton
本文介绍了选中并取消选中RadioButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够选中/选择一个单选按钮,然后取消选中/取消选中(如果他们偶然选择了错误的文件).
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?
推荐答案
我建议您使用Checkbox控件在实际可以执行要求的地方进行操作. > 但是单选按钮只是您要使用的参考以下代码:
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 :
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;
}
其中radioButton1是您正在使用的单选按钮的名称.
我已经使用了此控件的mousedown和mouseup事件.
where radioButton1 is the name of the radio button that you are using.
I have used the mousedown and mouseup events of this control.
您能解释清楚吗?
-----
我认为,这对您使用单选按钮列表并选择True为true很有帮助.
can u explain clear
-----
i think, this is help u use Radio Button List and Select Autopostback true.
您是否在谈论 ^ ]
正如Vinoth所说,您需要将autopostback属性设置为true.
Are you talking about OnCheckedChanged event[^]
As said by Vinoth you need to set autopostback property to true.
这篇关于选中并取消选中RadioButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文