Enumerate all controls in the form

private void EnableControls(bool enable)
        {
            foreach (TextBox t in Page.Form.Controls.OfType<TextBox>())
            {
                t.ReadOnly = !enable;
            }
            chkSameAsCurrent.Enabled = enable;
        }

The above code runs fine in a simple page not having any master page, but if I run it in a ContentPage I can not enumerate the TextBoxes and not even any control in the form.

Answers


Try this. I think this should work.

 private void RecursiveLoopThroughControls(Control root)
 {
      foreach (Control control in root.Controls)
      {
          RecursiveLoopThroughControls(control);
          //process the control.
      }
 }

Call the method using

 RecursiveLoopThroughControls(Page)

Need Your Help

When deploying Jasper Reports getting error message

jasper-reports ireport jasperserver

Hi I created a simple report using iReport 4.5.1 and when I tried to deploy the report in JasperSoft (Ver 4.5) I am getting the following error message even thought I am selecting the correct JRXML...

Copy a subtree in the nested set model Java/MySQL

mysql java tree

I'm using a nested set model to represent tree folders in a program. The table structure is :

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.