2012-11-21 2 views
0

이 CheckBoxList 컨트롤과이 컨트롤의 각 ListItem에 img HTML 태그로 Text 속성을 설정하여 이미지를 표시합니다.ASP.NET 체크 박스 컨트롤에서 틱/체크 상자 제거

각 항목을 클릭 할 때 ASP.NET CheckBoxList 컨트롤의 확인란에서 틱/확인란을 제거하려고합니다.

내 코드가이 작업을 수행합니다. 일부 체크 상자를 클릭 할 때마다 SelectedIndexChanged 이벤트가 발생하고 일부 데이터가 내 데이터베이스에 저장됩니다. 저장이 끝나고 페이지가 새로 고쳐지면 더 이상 클릭하지 않은 체크 박스 항목의 체크 박스/체크 박스를 체크하고 체크 박스를 비활성화하려면 체크 박스를 클릭 할 수 없도록해야합니다. 다시. Enable 및 Selected 속성을 False로 설정하고 CheckboxList 컨트롤에 특성을 추가하려고 시도했지만 성공하지는 못했습니다. 여기 내 코드가있다.

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 

그리고 여기에 CSS 클래스 : 다음 후

.displayCheckBox input{display:none;} 

이벤트가 데이터베이스에 저장을 수행하고 페이지가

<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> 

그리고 코드의

내가 이렇게 뒤에 새로 고침, 선택한 확인란은 사용할 수 없지만 틱/확인란이 표시되며 선택한 경우 표시하지 않습니다.

누구나 하나의 아이디어가 있습니다. 많이 검색했지만 CheckBoxList 컨트롤이 많은 costumizing 옵션을 제공하지 않는 것으로 보입니다.

미리 감사드립니다. 당신이 checkboxlist에서 체크 박스를 제거하려면

답변

0

,의 SelectedIndexChanged 이벤트, 이것을 시도 :

Private Sub Services_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Services.SelectedIndexChanged 

    '-----Storing to database code here------ 

    Services.Items.RemoveAt(Services.SelectedIndex) 
End Sub 
+0

안녕하세요 KLP를, 시간 내 주셔서 감사합니다. 아니요, 확인란 상자에서 확인란을 제거하고 싶지 않습니다. 사용자가 클릭 할 때 클릭 한 확인란에 눈금/확인란이 나타나지 않게하려고합니다. – Pier

관련 문제