Skip to content

Instantly share code, notes, and snippets.

@Phuseos
Created May 25, 2016 12:25
Show Gist options
  • Select an option

  • Save Phuseos/9c59fcec7ce5de0d1b6a38b9fd4b0c2a to your computer and use it in GitHub Desktop.

Select an option

Save Phuseos/9c59fcec7ce5de0d1b6a38b9fd4b0c2a to your computer and use it in GitHub Desktop.
Set all buttons on page to not enabled (C#)
protected void ButtonBlocker(Control Parent)
{ //Set all buttons on page to not enabled
//Call by using ButtonBlocker(Page);
foreach (Control c in Parent.Controls) //Loop through the controls on the page
{
Button bt = c as Button; if (bt != null)
{
bt.Enabled = false; //Set the buttons to not enabled.
//c.Visible = false; //Uncomment to make the buttons invisible.
}
if (c.HasControls()) { ButtonBlocker(c); }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment