, :
private void GetAllControlsOfType<TControl>(TControl collection, List<TControl> container) where TControl : Control
{
foreach(Control control in collection)
{
if(control is TControl)
container.Add(control);
if(control.HasControls())
GetAllControlsOfType<TControl>(control.Controls, container);
}
}
, , :
var checkboxes = new List<Checkbox>();
GetAllControlsOfType<Checkbox>(Page.Controls, checkboxes);
After that, it will contain Listall the checkbox controls. Then you can simply map them to a state objector simply follow these steps:
foreach(var checkbox in checkboxes)
checkbox.Checked = false;
To clear all checkboxes, keep in mind that this has not been checked, so fine tuning may be required.
source
share