jQuery's selectors are really powerful and flexible. JavaScript's original approach is also worth looking into.
<%@ Page Language="C#" AutoEventWireup= "true" CodeFile="CheckBoxList.aspx.cs" Inherits="CheckBoxList" %>
using System;
using System.Data;
using System .Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls ;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CheckBoxList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOk_Click(object sender, EventArgs e)
{
int totalNum = 0;//Total number
string list = "000"; //Selected value
for (int i = 0; i < this.chkBox.Items.Count; i )
{
if (chkBox.Items[i].Selected )
{
totalNum = 1;
list = "," chkBox.Items[i].Value;
}
}
Response.Write(totalNum.ToString() " |" list);
}
}