<%@ Page Language="C#" EnableEventValidation="false" %>
<!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)
{
FindBox(this.Controls);
}
private void FindBox(ControlCollection cc)
{
foreach (Control c in cc)
{
if (c.HasControls())
{
FindBox(c.Controls);
}
if (c is CheckBox)
{
CheckBox x = c as CheckBox;
//判断名称
if (x.Attributes["name"] != null && x.Attributes["name"].Equals("Admin_Power"))
{
Response.Write("<li>" + x.Attributes["name"]);
}
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form runat="server" id="form1">
<asp:CheckBox ID="CheckBox7" runat="server" name="xxxxx" Text=" xxxxx" />
<asp:CheckBox ID="CheckBox1" runat="server" name="Admin_Power" Text=" 投票1" />
<asp:CheckBox ID="CheckBox2" runat="server" name="Admin_Power" Text=" 投票2" />
<asp:CheckBox ID="CheckBox3" runat="server" name="Admin_Power" Text=" 投票3" />
<asp:CheckBox ID="CheckBox4" runat="server" name="Admin_Power" Text=" 投票4" />
<asp:CheckBox ID="CheckBox5" runat="server" name="Admin_Power" Text=" 投票5" />
<asp:CheckBox ID="CheckBox6" runat="server" name="Admin_Power" Text=" 投票6" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="得到" />
</form>
</body>
</html>