ASP.NET - Code Samples - Disable CheckboxList Items
来源:互联网 发布:小众香水 知乎 编辑:程序博客网 时间:2024/06/10 02:07
//Add This Code To the HTML directly
// checkboxlistID = id of the checkboxlist
// chkarray = array of indexes to set enable or disable
// disable = true to disable
<script language=javascript>
function disableListItems(checkBoxListId, chkArray, disable)
{
// Get the checkboxlist object.
objCtrl = document.getElementById(checkBoxListId);
// Does the checkboxlist not exist?
if(objCtrl == null)
{ return;
}
var i = 0;
// iterate through listitems that need to be enabled or disabled
for(i = 0; i<chkArray.length; i++)
{
objItem = document.getElementById(checkBoxListId + '_' + chkArray[i]);
if(objItem == null)
{
continue;
}
// Disable/Enable the checkbox.
objItem.disabled = disable;
// Should the checkbox be disabled?
objItem.checked = false;
}
}
</script>
'Add Code to the page load event (this demonstrates disabling the 2nd and 3rd items)
'Disable on intial Page Load
If Not Me.IsStartupScriptRegistered("doit") Then
Me.RegisterStartupScript("doit", "<script language=""javascript"">disableListItems('checkBoxList1',new Array(1,2),true);</script>")
End if
'Disable on checkboxlist click
CheckBoxList1.Attributes.Add("onclick", _
"disableListItems('checkBoxList1',new Array(1,2),true)")
// checkboxlistID = id of the checkboxlist
// chkarray = array of indexes to set enable or disable
// disable = true to disable
<script language=javascript>
function disableListItems(checkBoxListId, chkArray, disable)
{
// Get the checkboxlist object.
objCtrl = document.getElementById(checkBoxListId);
// Does the checkboxlist not exist?
if(objCtrl == null)
{ return;
}
var i = 0;
// iterate through listitems that need to be enabled or disabled
for(i = 0; i<chkArray.length; i++)
{
objItem = document.getElementById(checkBoxListId + '_' + chkArray[i]);
if(objItem == null)
{
continue;
}
// Disable/Enable the checkbox.
objItem.disabled = disable;
// Should the checkbox be disabled?
objItem.checked = false;
}
}
</script>
'Add Code to the page load event (this demonstrates disabling the 2nd and 3rd items)
'Disable on intial Page Load
If Not Me.IsStartupScriptRegistered("doit") Then
Me.RegisterStartupScript("doit", "<script language=""javascript"">disableListItems('checkBoxList1',new Array(1,2),true);</script>")
End if
'Disable on checkboxlist click
CheckBoxList1.Attributes.Add("onclick", _
"disableListItems('checkBoxList1',new Array(1,2),true)")
- ASP.NET - Code Samples - Disable CheckboxList Items
- .Net code samples
- 黑马程序员 ASP.NET中 CheckboxList.Items.Count=0的解决办法
- ASP.NET CheckBoxList 组件
- asp.net CheckBoxList 控件
- Visual C# .NET Code Samples
- Csharp:asp.net CheckBoxList databind
- Csharp:asp.net CheckBoxList databind
- asp.net core 绑定CheckBoxList
- ASP.NET中WebForm组件CheckBoxList编程
- ASP.NET CheckBoxList 用javascript 实现全选
- ASP.NET中WebForm组件CheckBoxList编程
- Asp.net(C#/2.0) 部分全选 CheckBoxList
- asp.net的checkboxlist绑定数据
- Asp.net 中CheckBoxList 的应用
- ASP.NET中Web组件CheckBoxList编程
- Asp.Net CheckBox嵌套绑定CheckBoxList
- ASP.NET页面的CheckBoxList组件
- struts-config.xml文件详解
- 对日合作WINCE C 开发工程师
- 如何访问其他进程的 socket 句柄?
- 使用Struts-config.xml来实现全局request编码转换
- Visual C#常用函数和方法集汇总
- ASP.NET - Code Samples - Disable CheckboxList Items
- Select()系统调用及文件描述符集fd_set的应用
- 对日合作C++/MFC开发工程师
- Select()函数
- Ip-adress.com:国际IP地址查询工具
- firebird
- 便利的开发编辑工具-vim
- 30岁,我的程序员梦想
- 各类session监听器的应用