Rudebox.co.nr How To Forums

Rudebox How To Forums - Ask Anything, View How To's
 
HomeFAQSearchRegisterMemberlistUsergroupsLog in

Share | 
 

 Enable Disable, all controls in a div / placeholder

View previous topic View next topic Go down 
AuthorMessage
Admin
Admin
avatar

Number of posts : 216
Registration date : 2007-01-01

PostSubject: Enable Disable, all controls in a div / placeholder   Mon Dec 03, 2007 5:49 pm

ASPX Page:

Code:
 <asp:PlaceHolder ID="placeHolderMyServerControl" runat="server"></asp:PlaceHolder>

Code Behind:

Call Function:
Code:


private bool condition;

protected override void CreateChildControls()
{
  base.CreateChildControls();
  MyServerControl serverControl = new MyServerControl();
  placeHolderMyServerControl.Controls.Add(serverControl);
}

protected override void OnPreRender(EventArgs e)
{
  base.OnPreRender(e);
  MyCondition();
  if(condition == true)
  {
    EnableControl(true, placeHolderMyServerControl.Controls);
  }
  else
  {
    EnableControl(false, placeHolderMyServerControl.Controls);
  }
}


Create Function:
Code:

/// <summary>
/// Enable Disable Control
/// </summary>
/// <param name="enabled">true or false</param>
/// <param name="controls">Controls Collection</param>
 private void EnableControl(bool enabled, ControlCollection controls)
        {
          foreach (Control childControl in control)
          {
              try
              {
                  WebControl webChildControl = (WebControl) childControl;
                  webChildControl.Enabled = enabled;
              }
              catch
              {
                 
              }
              finally
              {
                  EnableControl(enabled, childControl.Controls);
              }
          }
        }


//Your Condition
private void MyCondition()
{
//Put your own if condition
  if()
  {
  condition = true;
  }
  else
  {
  condition = false;
  }
}


=============
Back to top Go down
View user profile http://rudebox.editboard.com
 
Enable Disable, all controls in a div / placeholder
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Diablo 2 Improved Controls
» I can't enable script attached to gameObject (Photon Network)
» Warning regarding 6 piece Syzygys at long time controls.
» Skyrim - Enable Data Files Option
» Flight Controls

Permissions in this forum:You cannot reply to topics in this forum
Rudebox.co.nr How To Forums :: How To - Myspace / Website /Blog Utilities :: ASP .net-
Jump to: