|
Hello guys !
I have this CheckBoxList control and to each ListItem of it, have set the Text property to the img HTML tag so it displays an image.
I am trying to remove the tick/check box from the checkboxes of a ASP.NET CheckBoxList control when i click on each item.
My code does this. Every time i click on some check box, the **SelectedIndexChanged** event fires up and it does some saving of some data in my database. And when the saving is done and the page is refreshed i want to check/tick box of the checkbox item that was clicked not to be there anymore and the checkbox to be disabled cause i don't want the user to able able to click it again. I have tried to tried to set the Enable and Selected properties to False, and also add an attribute to the CheckboxList control, but without success. Here is my code.
<asp:CheckBoxList ID="Services" runat="server" RepeatColumns="5" CellPadding="10"
CellSpacing="15" RepeatLayout="Table"
Font-Size="Large" RepeatDirection="Vertical" TextAlign="Right"
AutoPostBack="true" EnableViewState="true">
<asp:ListItem Value="Facebook" Text="<img src='/ServiceIcons/facebook.png'
title='Facebook' />" />
<asp:ListItem Value="Googleplus" Text="<img src='/ServiceIcons/googleplus.png'
title='Google+' />" />
<asp:ListItem Value="LinkedIn" Text="<img src='/ServiceIcons/linkedin.png'
title='LinkedIn' />" />
<asp:ListItem Value="RSS" Text="<img src='/ServiceIcons/rss.png' title='RSS' />" />
<asp:ListItem Value="Skype" Text="<img src='/ServiceIcons/skype.png' title='Skype' />"
/>
</asp:CheckBoxList>
And in the code behind i do this:
Private Sub Services_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Services.SelectedIndexChanged
-----Storing to database code here------
Services.Items(Services.SelectedIndex).Enabled = False
Services.Items(Services.SelectedIndex).Attributes.Add("class",
"displayCheckBox")
Services.Items(Services.SelectedIndex).Selected = False
End Sub
And the css class here:
.displayCheckBox input{background:Green;}
After the the event does the storing in the databse, page refreshed the checkbox that was selected is disabled but it shows the tick/check box, and i don't want it to show it if is selected.
Any one has an idea. I have searched a lot, but it seems that the CheckBoxList control doesn't provide much costumizing options.
Thank you in advance !
|
|
|
|
|
I don't feel like reproducing the control, but did you try
Services.Items(Services.SelectedIndex).checked = False
|
|
|
|