<script runat="server" language="C#">
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" />
<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">
</form>
</body>
</html>
|