LINQ - The Uber FindControl
Also see: Using IronPython for Dynamic Expressions.
With a simple extension method to ControlCollection to flatten the control tree you can use LINQ to query the control tree:
public static class PageExtensions { public static IEnumerable<Control> All(this ControlCollection controls) { foreach (Control control in controls) { foreach (Control grandChild in control.Controls.All()) yield return grandChild; yield return control; } } }
Now I can do things like this:
// get the first empty textbox TextBox firstEmpty = accountDetails.Controls .All() .OfType<TextBox>() .Where(tb => tb.Text.Trim().Length == 0) .FirstOrDefault(); // and focus it if (firstEmpty != null) firstEmpty.Focus();
Pretty cool! I can do all sorts of querying of the control tree now. LINQ you are my h
Also see: LINQ - The Uber FindControl
Also see: Uniqueness Typing Simplified
Also see: Parallels adds “Express Windows Installation”
Also see: The obligatory Halo 2 partial review and thumbs up.
Also see: The influence of style upon methodology…
Also see: Uniqueness Typing Simplified
Also see: Stand alone FXCop download
Also see: ASP.NET MVC in CodePlex and Extensible Unit Testing
Also see: From C# to Java: Part 4
Also see: LINQ - The Uber FindControl
Also see: Parallels adds “Express Windows Installation”
Also see: LINQ - The Uber FindControl
Also see: Memory Model
Also see: Single source code base for Silverlight and WPF solutions
Also see: Solving big business problems in our little toolbox application. A use case for Project Distributor.
Also see: C# 3.0 Lambdas and Type Inference
ero.http://weblogs.asp.net/dfindley/archive/2007/06/29/linq-the-uber-findcontrol.aspx
