Rudebox.co.nr How To Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Rudebox.co.nr How To Forums

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

 

 Enable Disable, all controls in a div / placeholder

Go down 
AuthorMessage
Admin
Admin
Admin


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

Enable Disable, all controls in a div / placeholder Empty
PostSubject: Enable Disable, all controls in a div / placeholder   Enable Disable, all controls in a div / placeholder Icon_minitimeMon 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
https://rudebox.editboard.com
 
Enable Disable, all controls in a div / placeholder
Back to top 
Page 1 of 1
 Similar topics
-
» How to enable DirectX
» How Enable Start Menu Scrolling
» How to enable Graphics Hardware Acceleration

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: