1.ListBox控件: Items 、SelectedIndex 和 SelectedItem、Count
Items属性:用于获取LIST的项数
SelectedIndex:用于获取或设置LISTBOX中当前选定的从零开始的索引
SelectedItem:用于获取或设置LISTBOX中的当前选定项
2.CheckListBox控件:
SetItemCheckState(int index,CheckState value):进行FOR循环时设置该索引的选择状态
CheckedItems[i].ToString():获取CheckListBox中的一项(i)的值
for(int i=0;i <ckblist.items.count;i++)
{
if(ckblist.items[i].selected==true)
{
//进行相应操作...
}
}
3.CheckBox控件:
<asp:CheckBox ID="cb1" Checked="true" runat="server" οnclick="changeMark('cb1')" />
JS判断cb1是否被选中
function changeMark(objname)
{
alert(document.getElementById(objname).checked);
}
4.asp:DropdownList控件
通过JS获得选中的值,如
<asp:DropDownList ID="city" runat="server" οnchange="ddlPchange();" >绑定数据</asp:DropDownList>
省市联动的状态下
function ddlPchange()
{
var indexCity = document.getElementById('city').selectedIndex;
var citys = document.getElementById('city').value
var cityName = document.getElementById('city').options[indexCity].text;
}