【发布时间】:2010-09-07 03:01:30
【问题描述】:
我正在尝试使用 JavaScript 禁用一堆控件(以便它们回发值)。除了我的单选按钮之外,所有控件都可以正常工作,因为它们失去了价值。在下面通过递归函数调用以禁用所有子控件的代码中,永远不会命中第二个 else(else if (control is RadioButton)),并且 RadioButton 控件被标识为 Checkbox 控件。
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. 如何禁用它以便它回发它的值?
【问题讨论】:
标签: c# javascript asp.net