I’m trying to count all the checkbox controls on a page, I’d like to be able to count them based on what css class they are (or any other ID field I can use to group ValidationGroup, etc). I’m still pretty green to c#. Here’s my code:
protected void submitButton_Click(object sender, EventArgs e)
{
int numCbSelected = 0;
foreach (CheckBox cb in Page.Controls)
{
numCbSelected = numCbSelected + 1;
}
errLabel.Text = numCbSelected.ToString();
}
You’ll have to do some form of recursion to get all the checkboxes on the page
Then call it