Skip to content

Instantly share code, notes, and snippets.

@gerardolima
Created March 22, 2016 11:31
Show Gist options
  • Select an option

  • Save gerardolima/358a69c6159e584abc1f to your computer and use it in GitHub Desktop.

Select an option

Save gerardolima/358a69c6159e584abc1f to your computer and use it in GitHub Desktop.
/// ======================================================================
/// This gist is intended to be copy-and-pasted to the codebehind cs file
/// for a aspx page; please check the InitializeComponent before proceed.
/// ======================================================================
/// <summary>
/// The target page most likelly will have other event handlers, do not overwrite
/// them, just add the correct event hendler to the PreRender event.
/// </summary>
private void InitializeComponent() {
this.PreRender += new EventHandler(this.ShowAll); // bind the even handler
}
protected void ShowAll(object sender, EventArgs e)
{
ShowRecursive(MyPageUserInterfaceControl);
}
protected void ShowRecursive(System.Web.UI.Control container)
{
if(container == null) return;
foreach(var control in container.Controls.OfType<System.Web.UI.WebControls.PlaceHolder>().Where(it => it != null))
{
control.Visible = true;
ShowRecursive(control);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment