Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. WebControls vs. UserControls

WebControls vs. UserControls

Scheduled Pinned Locked Moved ASP.NET
htmlvisual-studiocomdesigncollaboration
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeremy Kimball
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • J Jeremy Kimball

      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

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 the HtmlTextWriter to their RenderContent 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

      J 2 Replies Last reply
      0
      • H Heath Stewart

        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 the HtmlTextWriter to their RenderContent 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

        J Offline
        J Offline
        Jeremy Kimball
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • H Heath Stewart

          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 the HtmlTextWriter to their RenderContent 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

          J Offline
          J Offline
          Jeremy Kimball
          wrote on last edited by
          #4

          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

          H 1 Reply Last reply
          0
          • J Jeremy Kimball

            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

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups