Search code examples
asp.netrenderweb-controls

What's the difference between Render and RenderControl in WebControl creation?


I've recently learned to write my own WebControls, but I'm still hazy on the difference between Render and RenderControl. I started out using Render, but at some point I started using RenderControl, which I now use exclusively. If I'm forming a bad habit I'd like to nip it in the bud now before I get set in my ways.


Solution

  • RenderControl is used if there is an existing control that provides what you want so you can take advantage of how that is rendered.

    Render is used if you need to take full control over how the html is rendered.

    You can of course combine the two for the most optimal use of your programming time...

    EDIT
    For a better explanation on this, and excellent point to what to use when, see the answer from mhenry1384.