Thursday, November 03, 2005

ASP.NET Control Trees

{

Debugging a problem today I wrote this, which may be useful to someone. It displays all the controls on an ASP.NET Page in a tree structure. You can actually call it from any control, it will recursively traverse the heirarchy below it. I tested it on ASP.NET 2.0, and it works fine:

Call it with the following:

DisplayControlTree(this.Controls, 1, 30);

Incidentally, the problem I had (and still have) comes from dynamically loading User Controls. Once they've been loaded using LoadControl("... path") they don't seem to persist themselves in the ViewState. I think my best hope for now is to save entries made to the User Controls by parsing the Querystring or Form collection manually.


}

No comments: