Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all CheckBoxes using C#?

Tags:

c#

asp.net

In Asp.net. how can I access every checkbox exists in the page using C# code ?

like image 297
Adham Avatar asked Dec 07 '22 17:12

Adham


1 Answers

This gets you every Checkbox on the page. You can change the form1 to whatever control you want to search inside of.

foreach (Control ctl in form1.Controls)
{
    if (ctl is CheckBox)
    {

    }
}

Alternatively if you know the ID of the control:

form1.FindControl("id");
like image 53
Adam Avatar answered Dec 26 '22 13:12

Adam