<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="C#" runat="server">
protected void Check1_SelectedIndexChanged( object sender, EventArgs e ) {
msg.Text = "<p>Selected Item(s):</p>";
for ( int i = 0; i < Check1.Items.Count; i++ )
if ( Check1.Items[i].Selected )
msg.Text += Check1.Items[i].Text;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title></title></head>
<body>
<form id="form1" runat="server">
<asp:CheckBoxList ID="Check1" runat="server"
AutoPostBack="True"
onselectedindexchanged="Check1_SelectedIndexChanged">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
<asp:ListItem>Item 6</asp:ListItem>
</asp:CheckBoxList>
<asp:Label ID="msg" runat="server"></asp:Label>
</form>
</body>
</html> |
|
|