我在頁面上有一個CheckBoxList
。頁面上的所有控件都在UpdatePanel
。CheckBoxList控件在回發後丟失所有項目
<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
你有沒有做過這方面的研究呢? – Popo 2013-05-11 13:59:54
也顯示您的JavaScript代碼! – 2013-05-11 14:09:44
onchange =「RemoveItems()」沒有做任何事情? – clamchoda 2013-05-12 04:30:43