is there a way to disable all the all the buttons on the page at once.?
if (Directory.Exists(folder))
{
all buttons enabled
}
else
{
All buttons disabled
Label4.Text = "Agent Share folder does not exists";
}
any suggestions thanks
pseudocode:
In a Windows Form environment something like this should work for you:
Edit:
You may actually need to do more than this. The Controls collection only fetches the controls that are the immediate children of a particular parent, and it doesn't recursively search through the entire page to find all the buttons. You could use something like the recursive function on this page to recursively find all the buttons and disable every last one of them.
If you add the code from the above linked page, your code would then be:
These kind of recursive methods will come in very handy in ASP.NET once you use them a couple of times.
Something among the lines might help:
which could be called like this:
As other answers have said, ultimately you will need to cycle through the page and find and disable containing elements. One way of mitigating this might be to place all of the necessary buttons in a panel (or multiple panels) and disable the panels in place of the buttons.