一、ListBox控件
1.定义:用于显示一组列表项。
2.常用属性:
ListBox控件的常用属性 属性说明Items获取列表控件项的集合SelectionMode获取或设置ListBox控件的选择格式SelectedIndex获取或设置列表控件中选定项的最低序号索引SelectedItem获取列表控件中索引最小的选中项SelectedValue获取列表控件中选定项的值,或选择列表控件中包含指定值的项Rows获取或设置ListBox控件中显示的行数 DataSource获取或设置对象,数据绑定控件从该对象中检索其数据项列表ID控件的唯一标识,不能重复(1)Items:,用来获取列表中的项,加载方式:1)属性面板添加;2)Items.Add添加
(2)SelectedMode:用来获取列表控件的选择模式,两种方式:1)单选;2)多选
后台代码:
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>页面形式:
页面代码:
<select size="4" name="ListBox1" id="ListBox1">二、DropDownList控件
1.定义:选择控件,只允许用户选择一项。
2.常用属性:
DropDownList的常用属性 属性说明Items获取列表控件项的集合SelectedIndex获取或设置列表中选定项的最低序号索引SelectedItem获取列表中选中的选项的索引SelectedValue获取列表控件中选定项的值,或选择列表控件中包含指定值的选项AutoPostBack获取或设置一个值,该值指示当用户更改列表中的选定内容时,是否自动产生向服务器回发DataSource获取或设置对象,数据绑定控件从该对象中检索其数据项列表ID获取或设置分配给服务器控件的编程标识符3.常用方法:1)用DataSource绑定数据源;2)用DataBind绑定数据
4.常用事件:SelectedIndexChanged,当控件中选定选项发生改变时,触发SelectedIndexChanged事件。
后台代码:
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>页面形式:
页面代码:
<select name="DropDownList1" id="DropDownList1">三、RadioButton控件与RadioButtonList控件
1.定义:RadioButton是单选按钮控件,RadioButtonList是单选按钮组。
2.常用属性:
RadioButton和RadioButtonList控件的常用属性 属性说明AutoPostBack获取或设置一个值,该值指示在单击控件时,是否自动回发到服务器CausesValidation获取或设置一个值,该值指示在单击控件时,是否执行验证Checked(RadioButtonList不存在此属性)标记RadioButton是否被选中GroupName获取或设置单选按钮所属的组名Text(RadioButtonList不存在此属性)获取或设置控件显示的文本TextAlign文本的对齐方式Enabled控件是否可用ID控件唯一标识,不能重复(1)GroupName:只有当不同的RadioButton控件的GroupName相同时,才能互斥。
后台代码:
<asp:RadioButton ID="RadioButton1" runat="server" text="1314"/> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem>1254</asp:ListItem> </asp:RadioButtonList>页面形式:
页面代码:
<input id="RadioButton1" type="radio" name="RadioButton1" value="RadioButton1" /><label for="RadioButton1">1314</label> <table id="RadioButtonList1"> <tr> <td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="1254" /><label for="RadioButtonList1_0">1254</label></td> </tr>五、CheckBox控件与CheckBoxList控件
1.定义:CheckBox控件是复选框,CheckBoxList控件是一组复选框
2.常用属性:
CheckBox和CheckBoxList控件的常用属性 属性说明AutoPostBack获取或设置一个值,该值指示在单击控件时,是否自动回发到服务器CausesValidation获取或设置一个值。该值指示在单击控件时,是否执行验证Checked(CheckBoxList不存在此属性)表示是否选中Text(CheckBoxList不存在此属性)控件的文本TextAlign文本对齐方式Enabled控件是否可用ID控件唯一标识,不能重复3.常用事件:
CheckChanged事件:
后台代码:
<asp:CheckBox ID="CheckBox1" runat="server" text="123"/> <asp:CheckBoxList ID="CheckBoxList1" runat="server"> <asp:ListItem>1321</asp:ListItem> </asp:CheckBoxList>页面形式:
页面代码:
<input id="CheckBox1" type="checkbox" name="CheckBox1" /><label for="CheckBox1">123</label> <table id="CheckBoxList1"> <tr> <td><input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" value="1321" /><label for="CheckBoxList1_0">1321</label></td> </tr>
转载于:https://www.cnblogs.com/bosamvs/p/5687191.html
相关资源:移动端日期时间选择控件