Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach(Label l in Controls) // setting all labels' s visbility on page to true
- l.Visible =true;
- private void SetVisibility<T>(Control parent, bool isVisible)
- {
- foreach (Control ctrl in parent.Controls)
- {
- if(ctrl is T)
- ctrl.Visible = isVisible;
- SetVisibility<T>(ctrl, isVisible);
- }
- }
- SetVisibility<Label>(Page, true);
- foreach(Label l in Controls.OfType<Label>())
- {
- l.Visible = true;
- }
- foreach(control l in Controls) {
- if(l is System.Web.UI.WebControls.Label)
- l.Visible = true;
- }
- foreach(Control l in Controls)
- if (l is Label) l.Visible =true;
- public static void SetAllControls( Type t, Control parent /* can be Page */)
- {
- foreach (Control c in parent.Controls)
- {
- if (c.GetType() == t) c.Visible=true;
- if (c.HasControls()) GetAllControls( t, c);
- }
- }
- SetAllControls( typeof(Label), this);
- public void Search(Control control)
- {
- foreach (Control c in control.Controls)
- {
- if (c.Controls.Count > 0)
- Search(c);
- if (c is Label)
- c.Visible = false;
- }
- }
- Search(this.Page);
Add Comment
Please, Sign In to add comment