我在页面上有一个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