CreateChildControls or Render in SharePoint 2010 webparts?

I get this question a lot by developers, both budding SharePoint developers and grizzled veterans. Well, the veterans mainly ask what the point of using Render is…

It’s quite simple, really; if you want interactivity then you need to override CreateChildControls() (and remember to call the base method as well), while if you’re only displaying data, go ahead and override Render().

Overriding Render() can save you quite a bit of memory and increase performance a lot, and since the majority of webparts tend to be about simply displaying data in different ways, by all means go ahead and use it.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.