Disable specific controls in a collection
For a recent project, I had to deal with a fair number of controls on a page that all needed to be disabled at once. This is the function that I wrote to do so:
void DisableControls(List types, ControlCollection controls) {
foreach(Control control in controls) {
if(types.Contains(control.GetType())) {
((WebControl)control).Enabled = false;
}
}
}
Leave a Reply