.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Finding controls a recursive iteration

Posted By:nishithraj       Posted Date: December 28, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

If we require to find the controls we can implement the following code.

Here the application will check the controls reside inside of a particular control named root.

It's a recursive and effective iteration.

We can retrieve them and also can be hided or disabled dynamically.

It searches even in a page.

private void FindControlsRecursive(Control root, ref ArrayList list)
            if (root.Controls.Count != 0)
                foreach (Control c in root.Controls)
                    if (c.GetType().ToString().Equals("System.Web.UI.WebControls.Button"))
                        if (int.Parse(GetSession(GrantSessions.UserID)) != 1)
                            c.Visible = false;
                    else if (c.HasControls())
                        FindControlsRecursive(c, ref list);


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend