Problem in disbaleing list items of checkboxlist

G

Guest

Hi

I am populating a checkboxlist dynamically from a database and want to check the default values and disable them , so that teh user can not uncheck the defualt checked values.
I am not able to disable the listitems .I do not see the disabled or enabled property for the list items of checkboxlist.
Is there any way to add this attribute dynamically

Your help is greatly appreciated. Thanks.
 
S

serhat tuncay

You can use javascript to overcome this problem. For example, the following code segment disables the last checkbox in the given checkbox list.As you see, below javascript is executed as the onload event handler (at client side) of the page and disables the desired checkbox

<script language="javascript"

function OnInitHandler(

var publicChkBox = document.getElementById('cblAccessRights_3')

if ( publicChkBox != null

publicChkBox.disabled = true


</script

<body MS_POSITIONING="GridLayout" onload="OnInitHandler()"
<form id="Form1" method="post" runat="server"
<asp:CheckBoxList id="cblAccessRights" runat="server" Width="232px" CssClass="clearTable"
<asp:ListItem Value="user" Selected="True">user</asp:ListItem
<asp:ListItem Value="Administrator" Selected="True">Administrator user</asp:ListItem
<asp:ListItem Value="Internal" Selected="True">Internal</asp:ListItem
<asp:ListItem Value="Public">Public denied access</asp:ListItem
</asp:CheckBoxList></TD
</form

regards
Serhat Tuncay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top