asp.net(c#)web服务器控件,多选框checkboxlist控件。
2005-03-16 10:08
721 查看
<%@ Page Language="c#" %>
<script runat="server">
void Page_Load()
{
string msg = "You have selected the following items:<br />";
if (check1.Items[0].Selected) {
msg = msg + check1.Items[0].Text + "<br />";
}
if (check1.Items[1].Selected) {
msg = msg + check1.Items[1].Text + "<br />";
}
if (check1.Items[2].Selected) {
msg = msg + check1.Items[2].Text + "<br />";
}
Message.Text = msg;
}
</script>
<html>
<head>
<title>Check Box List Example</title>
</head>
<body>
<asp:Label id="Message" runat="server"></asp:Label>
<br />
<br />
Which city do you wish to look at hotels for?
<br />
<br />
<form runat="server">
<asp:checkboxlist id="check1" runat="server">
<asp:listitem id="option1" runat="server" value="Madrid" />
<asp:listitem id="option2" runat="server" value="Oslo" />
<asp:listitem id="option3" runat="server" value="Lisbon" />
</asp:checkboxlist>
<br />
<br />
<input type="submit" value="提交查询内容" />
</form>
</body>
</html>
<script runat="server">
void Page_Load()
{
string msg = "You have selected the following items:<br />";
if (check1.Items[0].Selected) {
msg = msg + check1.Items[0].Text + "<br />";
}
if (check1.Items[1].Selected) {
msg = msg + check1.Items[1].Text + "<br />";
}
if (check1.Items[2].Selected) {
msg = msg + check1.Items[2].Text + "<br />";
}
Message.Text = msg;
}
</script>
<html>
<head>
<title>Check Box List Example</title>
</head>
<body>
<asp:Label id="Message" runat="server"></asp:Label>
<br />
<br />
Which city do you wish to look at hotels for?
<br />
<br />
<form runat="server">
<asp:checkboxlist id="check1" runat="server">
<asp:listitem id="option1" runat="server" value="Madrid" />
<asp:listitem id="option2" runat="server" value="Oslo" />
<asp:listitem id="option3" runat="server" value="Lisbon" />
</asp:checkboxlist>
<br />
<br />
<input type="submit" value="提交查询内容" />
</form>
</body>
</html>
相关文章推荐
- ASP.NET - CheckBox 和 CheckBoxList Web 服务器控件概述(下)
- ASP.NET - CheckBox 和 CheckBoxList Web 服务器控件概述(上)
- ASP.NET - BulletedList Web 服务器控件概述
- 教学思路ASP.Net之服务器控件:三、DropDownList、ListBox、CheckBoxList、RadioButtonList控件
- 教学思路ASP.Net之服务器控件:三、DropDownList、ListBox、CheckBoxList、RadioButtonList控件
- ASP.Net WEB控件 [ 复选框组 CheckBoxList控件 ]
- ASP.net 服务器控件: DropDownCheckBoxList 下拉多选框
- 用JavaScript获取Asp.net服务器端控件CheckBoxList的选中值数组
- ASP.NET自定义Web服务器控件-DropDownList/Select下拉列表控件
- ASP.NET自定义Web服务器控件-login登录控件
- 动态创建 ASP.NET Web 服务器控件模板(出自MSDN)
- ASP.NET 数据绑定 Web 服务器控件概述
- ASP.NET - SqlDataSource Web 服务器控件概述
- c#枚举类型在web控件CheckBoxList,RadioButtonList,DropDownList中的应用
- c# web 如何使用RequiredFieldValidator控件验证CheckBoxList
- ASP.NET - ImageMap Web 服务器控件概述(二)
- ASP.NET - Literal Web 服务器控件概述
- ASP.NET - MultiView 和 View Web 服务器控件概述(一)
- ASP.NET - Panel Web 服务器控件概述
- ASP.NET -自定义 TreeView Web 服务器控件的外观