checkboxlist

代码:

<script  runat="server">

Sub Check(sender As Object, e As EventArgs)

   dim i

   mess.Text="<p>Selected Item(s):</p>"

   for i=0 to check1.Items.Count-1

     if check1.Items(i).Selected then

       mess.Text+=check1.Items(i).Text + "<br>"

     end if

   next

End Sub

</script>

 

<!DOCTYPE html>

<html>

<body>

 

<form runat="server">

<asp:CheckBoxList id="check1" AutoPostBack="True"

TextAlign="Right" OnSelectedIndexChanged="Check"

runat="server">

<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>

<br>

<asp:label id="mess" runat="server"/>

</form>

 

</body>

</html>

结果:

相关文章