我试图禁用一堆JavaScript控件(以便它们回发值)。除了我的单选按钮,所有的控件都能正常工作,因为它们失去了价值。在通过递归函数调用以禁用所有子控件的下面的代码中,第二个else(else if(控件是RadioButton
))从未被击中,并且RadioButton控件被识别为Checkbox
控件。使用javascript禁用asp.net单选按钮
private static void DisableControl(WebControl control)
{
if (control is CheckBox)
{
((CheckBox)control).InputAttributes.Add("disabled", "disabled");
}
else if (control is RadioButton)
{
}
else if (control is ImageButton)
{
((ImageButton)control).Enabled = false;
}
else
{
control.Attributes.Add("readonly", "readonly");
}
}
两个问题:
1.如何识别控制是一个单选按钮?
2.如何禁用它以便将其值回传?