📄 checkboxlist.aspx
字号:
<html>
<head>
</head>
<script language="C#" runat="server">
void Button1_Click(object Source, EventArgs e) {
String s = "您选择了:<br>";
for (int i=0; i < Check1.Items.Count; i++)
{
if ( Check1.Items[ i ].Selected )
{
// List the selected items
s = s + Check1.Items[i].Text;
s = s + "<br>";
}
}
Label1.Text = s;
}
void chkLayout_CheckedChanged(Object sender, EventArgs e) {
if (chkLayout.Checked == true) {
Check1.RepeatLayout = RepeatLayout.Table;
}
else {
Check1.RepeatLayout = RepeatLayout.Flow;
}
}
void chkDirection_CheckedChanged(Object sender, EventArgs e) {
if (chkDirection.Checked == true) {
Check1.RepeatDirection = RepeatDirection.Horizontal;
}
else {
Check1.RepeatDirection = RepeatDirection.Vertical;
}
}
</script>
<body>
<H3>使用CheckBoxList控件</h3>
<Hr>
<form runat=server>
<table border="0" width="100%">
<tr>
<td width="73%">
<asp:CheckBoxList id=Check1 runat="server">
<asp:ListItem>香蕉</asp:ListItem>
<asp:ListItem>苹果</asp:ListItem>
<asp:ListItem>柚子</asp:ListItem>
<asp:ListItem>葡萄</asp:ListItem>
<asp:ListItem>甘蔗</asp:ListItem>
<asp:ListItem>桃子</asp:ListItem>
</asp:CheckBoxList>
</td>
<td width="27%">
<asp:CheckBox id=chkLayout OnCheckedChanged="chkLayout_CheckedChanged" Text="垂直排列" Checked=true AutoPostBack="true" runat="server" />
<br>
<asp:CheckBox id=chkDirection OnCheckedChanged="chkDirection_CheckedChanged" Text="水平排列" AutoPostBack="true" runat="server" />
<br>
<asp:Button id=Button1 Text="提交" onclick="Button1_Click" runat="server"/>
</td>
</tr>
</table>
<asp:Label id=Label1 font-name="Verdana" font-size="12pt" runat="server"/>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -