The ASP.NET Checkboxlist control provides a way for you to add checkboxes as listitems.
While this control makes working with multiple checkboxes much easier it lacks one very key item, an enable property. The only workaround for this at the moment is to add a javascript function which does the enabling and disabling automatically.
Below is javascript that will enable or disable on listitems(Checkbox 5) on listitems (Checkbox 1)
Javascript
function
EnableDisableCheckbox() {
var
chkList2 = document.getElementById('<%=CheckBoxList1.ClientID
%>');
var
checkbox2 = chkList2.getElementsByTagName("input");
if
(checkbox2[0].checked) {
checkbox2[1].disabled = false;
}
else
{
checkbox2[1].disabled = true;
}
}
HTML
<asp:CheckBoxList ID="CheckBoxList1"
runat="server"
Width="109px">
<asp:ListItem Value="1">Check Box 1</asp:ListItem>
<asp:ListItem Value="2">Check Box 2</asp:ListItem>
<asp:ListItem Value="3">Check Box 3</asp:ListItem>
<asp:ListItem Value="4">Check Box 4</asp:ListItem>
<asp:ListItem Value="5">Check Box 5</asp:ListItem>
<asp:ListItem Value="6">Check Box 6</asp:ListItem>
<asp:ListItem Value="7">Check Box 7</asp:ListItem>
<asp:ListItem Value="8">Check Box 8</asp:ListItem>
</asp:CheckBoxList>
its not working
ReplyDeleteNice blog to read, Thanks for sharing this valuable article.
ReplyDeleteBig Data Training Institute in Pune
Big Data Analytics Training in Pune