62,047
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
foreach (Control c in form1.Controls)
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
{
CheckBox box = c as CheckBox;
if(box.Checked)
{
Response.Write("<li>你选中的 ID=:"+ box.ID + " 值是:" +box.Text);
}
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td>
<div class="iInput">
<asp:CheckBox ID="C1" runat="server" Text=" 1"></asp:CheckBox></div>
</td>
<td>
<div class="iInput">
<asp:CheckBox ID="C2" runat="server" Text=" 2"></asp:CheckBox></div>
</td>
<td>
<div class="iInput">
<asp:CheckBox ID="C3" runat="server" Text=" 3"></asp:CheckBox></div>
</td>
</tr>
<tr>
<td>
<div class="iInput">
<asp:CheckBox ID="C4" runat="server" Text=" 4"></asp:CheckBox></div>
</td>
<td>
<div class="iInput">
<asp:CheckBox ID="C5" runat="server" Text=" 5"></asp:CheckBox></div>
</td>
<td>
<div class="iInput">
<asp:CheckBox ID="C6" runat="server" Text=" 6"></asp:CheckBox></div>
</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" Text="得到选中的值" onclick="Button1_Click" />
</form>
</body>
</html>