title: How to disable the controls in an ASP.NET page when the usercontrol is selected?
body: <p>I Successfully created an user control for displaying Error message. now everything works fine but when the message is shown the background controls can be accessed. how to disable the page controls or page from clicking or selecting any controls. and when the message panel is closed it should enable the page controls.</p>
  
  <p>i found the answer friends.</p>
  
  <pre><code>void DisableControls(Control parent, bool status)
      {
      foreach (Control c in parent.Controls)
              {
                  if (c is DropDownList)
                  {
                      ((DropDownList)(c)).Enabled = status;
                  }
                  if (c is Button)
                  {
                      ((Button)(c)).Enabled = status;
                  }
                  if (c is TextBox)
                  {
                      ((TextBox)c).Enabled = status;
                  }
  
                  if (c is RadioButton)
                  {
                      ((RadioButton)c).Enabled = status;
                  }
                  if (c is ImageButton)
                  {
                      ((ImageButton)c).Enabled = status;
                  }
                  if (c is CheckBox)
                  {
                      ((CheckBox)c).Enabled = status;
                  }
                  if (c is DropDownList)
                  {
                      ((DropDownList)c).Enabled = status;
                  }
                  if (c is HyperLink)
                  {
                      ((HyperLink)c).Enabled = status;
                  }
                  if (c is GridView)
                  {
                      ((GridView)c).Enabled = status;
                  }
                  if (c is Table)
                  {
                      ((Table)c).Enabled = status;
                  }
                  if (c is Menu)
                  {
                      ((Menu)c).Enabled = status;
                  }
                  if (c is TreeView)
                  {
                          ((TreeView)c).Enabled = status;
                      } 
  }
          }
  </code></pre>