<table id="radsBusinessType" border="0">
<tr>
<td><input id="radsBusinessType_0" type="radio" name="radsBusinessType" value="0" checked="checked" /><label for="radsBusinessType_0"><font color="black">变更</font></label></td><td><span disabled="disabled"><input id="radsBusinessType_1" type="radio" name="radsBusinessType" value="1" disabled="disabled" /><label for="radsBusinessType_1"><font color="black">申请</font></label></span></td>
</tr>
</table>
CheckBoxlist解析出的HTML代码如下:
<table id="chksAssignContent" border="0">
<tr>
<td><span disabled="disabled"><input id="chksAssignContent_0" type="checkbox" name="chksAssignContent$0" checked="checked" disabled="disabled" /><label for="chksAssignContent_0"><font color="black">申请AD帐号</font></label></span></td><td><span disabled="disabled"><input id="chksAssignContent_3" type="checkbox" name="chksAssignContent$3" checked="checked" disabled="disabled" /><label for="chksAssignContent_3"><font color="black">申请ERP帐号</font></label></span></td><td><span disabled="disabled"><input id="chksAssignContent_5" type="checkbox" name="chksAssignContent$5" disabled="disabled" /><label for="chksAssignContent_5"><font color="black">申请数字证书</font></label></span></td>
</tr><tr>
<td><span disabled="disabled"><input id="chksAssignContent_1" type="checkbox" name="chksAssignContent$1" disabled="disabled" /><label for="chksAssignContent_1"><font color="black">申请公司邮箱</font></label></span></td><td><span disabled="disabled"><input id="chksAssignContent_4" type="checkbox" name="chksAssignContent$4" disabled="disabled" /><label for="chksAssignContent_4"><font color="black">申请标准ERP岗位权限</font></label></span></td><td><span disabled="disabled"><input id="chksAssignContent_6" type="checkbox" name="chksAssignContent$6" disabled="disabled" /><label for="chksAssignContent_6"><font color="black">ERP岗位权限变更</font></label></span></td>
</tr><tr>
<td><span disabled="disabled"><input id="chksAssignContent_2" type="checkbox" name="chksAssignContent$2" disabled="disabled" /><label for="chksAssignContent_2"><font color="black">申请ERP额外权限</font></label></span></td><td></td><td></td>
</tr>
</table>
处理方法如下:
1.HTML页面调用:
<script src="http://www.cnblogs.com/JavaScript/ResetPage.js" type="text/javascript"></script>
<body onload="DeeperColorForRadioAndCheck()">
2.cs文件调用:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (!radsBusinessType.Enabled)
{
radsBusinessType.Enabled = true;
Common.SetRaddionbuttonlistForeColor(radsBusinessType.Items);
}
if (!chksAssignContent.Enabled)
{
chksAssignContent.Enabled = true;
Common.SetCheckBoxlistForeColor(chksAssignContent.Items);
}
}
公共方法:
public static void SetRaddionbuttonlistForeColor(ListItemCollection items)
{
if (items.Count >1)
{
foreach (ListItem item in items)
{
if (!item.Selected)
{
item.Enabled = false;
}
item.Text = "<font color=\"black\">" + item.Text + "</font>";
}
}
}
public static void SetCheckBoxlistForeColor(ListItemCollection items)
{
if (items.Count > 1)
{
foreach (ListItem item in items)
{
item.Enabled = false;
item.Text = "<font color=\"black\">" + item.Text + "</font>";
}
}
}
ResetPage.js文件:
//置raddionbutton
function DeeperColorForRadio() {
var InputTotal = document.all.tags("INPUT").length;
for (i = 0; i < InputTotal; i++) {
if (document.all.tags("INPUT")[i].type == "radio" && document.all.tags("INPUT")[i].disabled == true) {
document.all.tags("INPUT")[i].parentElement.disabled = false;
}
}
}
//checkbox
function DeeperColorForCheckBox() {
var InputTotal = document.all.tags("INPUT").length;
for (i = 0; i < InputTotal; i++) {
if (document.all.tags("INPUT")[i].type == "checkbox" && document.all.tags("INPUT")[i].disabled == true) {
document.all.tags("INPUT")[i].parentElement.disabled = false;
}
}
}
//
function DeeperColorForRadioAndCheck() {
DeeperColorForRadio();
DeeperColorForCheckBox();
}