No 27 · checkboxlist的使用
来源:互联网 发布:数据库的开发 编辑:程序博客网 时间:2024/05/20 10:55
<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head > <title > CheckBoxList组 </title > <script runat = "server" > protected void Button_Click ( object sender , EventArgs e ) { lblResult . Text = "" ; for ( int i = 0 ; i < ChkList . Items . Count ; i++ ) { if( ChkList . Items [ i ] . Selected ) { lblResult . Text += ChkList . Items [ i ] .Text + " <br > " ; } } } </script > </head > <body > <form runat = "server" id="Form1" > <table style="width: 436px"> <tr> <td colspan="3" style="height: 20px" align="center"> 请选择你所需要学习的计算机语言类型: </td> </tr> <tr> <td colspan="3"> <asp:CheckBoxList id = "ChkList" RepeatDirection = Horizontal runat = "server" Height="35px" > <asp:ListItem > Visual C++ .Net </asp:ListItem > <asp:ListItem > Visual C# </asp:ListItem > <asp:ListItem > VB.NET </asp:ListItem > <asp:ListItem > JScript.NET </asp:ListItem > <asp:ListItem > Visual J# </asp:ListItem > </asp:CheckBoxList ></td> </tr> <tr> <td colspan="2" style="width: 67px"> <asp:Button ID="Button1" runat="server" OnClick="Button_Click" Text="提交" Width="95px" /></td> <td style="width: 283px"> <span style="color: #ff0000">你选择的计算机语言型为:</span></td> </tr> <tr> <td colspan="3" style="height: 14px" align="center"> <asp:Label id = "lblResult" runat = "server" Width="75px" ></asp:Label></td>