Composite Controls Versus User Controls





Composite Controls Versus User Controls

Composite controls aren't the only way to bundle pieces of UI together. You can do the very same thing in user controls, which act as "mini pages" of sorts. As with many aspects of ASP.NET programming, the same task can be accomplished in a declarative way or a programmatic way. User controls are significantly more declarative because you can load up an .ascx file with markup, write a little "glue" code, and be on your way. Composite controls, on the other hand, require a programmatic approach, where you create each individual object and manipulate it, as well as the surrounding markup.

One disadvantage to composite controls is that you are, for the most part, tied into a particular "look" for the UI (though you can obviously create all kinds of style properties and even skin the individual controls). I would venture that the Login control's fairly rigid layout may deter a lot of people from using it (the control is essentially a composite control).

The big advantage of server controls is the very precise control you have over every aspect of the rendered HTML. You can decide how much to render, the order in which to render it, and so on, and therefore you can be in complete control of its performance. It's also very easy to distribute your work when compiled to an assembly. When other coders get the assembly, they drop it in their /bin folder, add two lines of code to their page, and it's done (and you look like a hero).


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows