WebControls vs. UserControls
-
I'm trying to come up with a presentation about what UserControls and WebControls are, the usages, differences, etc., for my team here at work. Here's what I got so far: UserControls: Kind of like big HTML include files. Generally contains a visual element (UI). Used mainly to build reoccuring pieces of a site (header, footer, login control), generally not very code-heavy. Portable in the sense that they don't require compiled assemblies to be transferred to the client. Not supported by Toolbox designer. WebControls: More akin to ActiveX components. Compiled assemblies that are transferred to the client. May or may not have a visual component. Geared toward reuse of building blocks of code, not neccesarily building blocks of HTML code. Supported by Toolbox designer First off, am I generally "right"? :) Secondly, anyone have any useful research links handy that explain this issue further? Much thanks, [edit: sorry, shouldn't have used the pre tag X| ]
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
-
I'm trying to come up with a presentation about what UserControls and WebControls are, the usages, differences, etc., for my team here at work. Here's what I got so far: UserControls: Kind of like big HTML include files. Generally contains a visual element (UI). Used mainly to build reoccuring pieces of a site (header, footer, login control), generally not very code-heavy. Portable in the sense that they don't require compiled assemblies to be transferred to the client. Not supported by Toolbox designer. WebControls: More akin to ActiveX components. Compiled assemblies that are transferred to the client. May or may not have a visual component. Geared toward reuse of building blocks of code, not neccesarily building blocks of HTML code. Supported by Toolbox designer First off, am I generally "right"? :) Secondly, anyone have any useful research links handy that explain this issue further? Much thanks, [edit: sorry, shouldn't have used the pre tag X| ]
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
WebControls are little like ActiveX components (by which I assume you mean server-side components). ActiveX has one major draw-back - its activation type. It's also late-binding, not type safe, and requires separate installation. The biggest difference between UserControls and WebControls is that UserControls contain HTML, where WebControls render HTML programmatically (UserControls can to, but you have to be careful). UserControls are also
INamingContainers
, thus becoming a parent for other controls (though the interface is only a marker for ASP.NET to know that the parent name should also be included). A UserControl is also a template control, which is what allows the embedded of child controls into the content stream. WebControls can include child controls, but you have to render their content yourself (typically just passing theHtmlTextWriter
to theirRenderContent
methods). With these properties, UserControls are great for "includes", which is a great way of putting it. I typically use them for more static web sites for headers, footers, and navbars. WebControls work great when you want more control over the rendering of a control, which I typically use navbars for more dynamic sites and other composite controls where I want a lot of control.Microsoft MVP, Visual C# My Articles
-
WebControls are little like ActiveX components (by which I assume you mean server-side components). ActiveX has one major draw-back - its activation type. It's also late-binding, not type safe, and requires separate installation. The biggest difference between UserControls and WebControls is that UserControls contain HTML, where WebControls render HTML programmatically (UserControls can to, but you have to be careful). UserControls are also
INamingContainers
, thus becoming a parent for other controls (though the interface is only a marker for ASP.NET to know that the parent name should also be included). A UserControl is also a template control, which is what allows the embedded of child controls into the content stream. WebControls can include child controls, but you have to render their content yourself (typically just passing theHtmlTextWriter
to theirRenderContent
methods). With these properties, UserControls are great for "includes", which is a great way of putting it. I typically use them for more static web sites for headers, footers, and navbars. WebControls work great when you want more control over the rendering of a control, which I typically use navbars for more dynamic sites and other composite controls where I want a lot of control.Microsoft MVP, Visual C# My Articles
Excellent, so I'm not overly off-base in my thoughts. Thanks a bunch, Heath. Microsoft was damned smart to give you that MVP :)
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
-
WebControls are little like ActiveX components (by which I assume you mean server-side components). ActiveX has one major draw-back - its activation type. It's also late-binding, not type safe, and requires separate installation. The biggest difference between UserControls and WebControls is that UserControls contain HTML, where WebControls render HTML programmatically (UserControls can to, but you have to be careful). UserControls are also
INamingContainers
, thus becoming a parent for other controls (though the interface is only a marker for ASP.NET to know that the parent name should also be included). A UserControl is also a template control, which is what allows the embedded of child controls into the content stream. WebControls can include child controls, but you have to render their content yourself (typically just passing theHtmlTextWriter
to theirRenderContent
methods). With these properties, UserControls are great for "includes", which is a great way of putting it. I typically use them for more static web sites for headers, footers, and navbars. WebControls work great when you want more control over the rendering of a control, which I typically use navbars for more dynamic sites and other composite controls where I want a lot of control.Microsoft MVP, Visual C# My Articles
Just to make sure, when you were talking about the better activation model, are you referring to not needing to do reference counting anymore? I forget the new-fangled way it does it...something like "Leasing"?
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
-
Just to make sure, when you were talking about the better activation model, are you referring to not needing to do reference counting anymore? I forget the new-fangled way it does it...something like "Leasing"?
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
Referencing counting isn't necessary for managed Types - the GC handles all that. "Leasing" is a term used in .NET Remoting, not ASP.NET. A lease is acquired by sponsers, who keep the object alive in such a case. Of course, the threading model isn't a problem like it is for ActiveX components in ASP, either.
Microsoft MVP, Visual C# My Articles