1

CheckBoxListオンページがあります。ページ上のすべてのコントロールはUpdatePanel.

 <asp:CheckBoxList ID="AreaCheckBoxList" Width="300px" runat="server" onchange="RemoveItems()" RepeatDirection="Horizontal">
  <asp:ListItem Value="" style="display: none"></asp:ListItem>
 </asp:CheckBoxList>

javascript でアンカータグをクリックするとアイテムが追加されます。

 <a class="button" onclick="addToCheckBoxListControl()" />

 function addToCheckBoxListControl() {

        var tableRef = document.getElementById('<%= AreaCheckBoxList.ClientID %>');
        var list = document.getElementById('<%= AreaDropDownList.ClientID  %>');
        var valueValue = list.options[list.selectedIndex].value;
        var textvalue = list.options[list.selectedIndex].text;
        if (!isValueAlreadyExist(tableRef, valueValue)) {
            var rowArray = tableRef.getElementsByTagName('tr');
            var rowCount = rowArray.length;
            var rowElement = tableRef.insertRow(rowCount);
            var columnElement = rowElement.insertCell(0);

            var checkBoxRef = document.createElement('input');

            var labelRef = document.createElement('label');

            checkBoxRef.type = 'checkbox';
            checkBoxRef.value = valueValue;
            labelRef.innerHTML = textvalue;

            columnElement.appendChild(checkBoxRef);
            columnElement.appendChild(labelRef);
        }
    }

ページにボタンがあり、CheckBoxListボタンのクリック後にすべてのアイテム (javascript で追加されたアイテム) を失うコントロールがあります。

AreaCheckBoxList.Items.Count -----> =1
4

1 に答える 1