foreach(Label l in Controls) // setting all labels' s visbility on page to true
l.Visible =true;
But on running ,i am getting following error
Unable to cast object of type 'ASP.admin_master' to type 'System.Web.UI.WebControls.Label'.
If one of the controls is not of type label, you'll get that error.
You could try:
foreach(Label l in Controls.OfType<Label>())
{
l.Visible = true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With