Reputation: 2249
This is my code:
public void SetLabelVisibilityFalse()
{
foreach(Control cntrl in this.Page.Form.Controls)
{
if(cntrl is Label)
{
Label lbl = ((Label)cntrl);
lbl.Visible = false;
}
}
}
but i am unable to access any of the control ... it is setting NO label on the page as false.. where am i wrong?
Upvotes: 0
Views: 24
Reputation: 26
if you are using master page than first you want to find Contentplaceholder than you can find any control of that page
public void SetLabelVisibilityFalse()
{
ContentPlaceHolder mycont = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
foreach (Control cntrl in mycont.Controls)
{
if (cntrl is Label)
{
Label lbl = ((Label)cntrl);
lbl.Visible = false;
}
}
Upvotes: 1