Quick tip: Use (or, avoid using) the “base.CreateChildControls()” method

You might have noticed the method “base.CreateChildControls()” being used in some of the webpart examples I’ve been sharing. It turns out that the method is not entirely needed in those webparts. According to the MSDN article:

Often the CreateChildControls only does a “final polish” on the controls, such as setting the tab index of the child controls, or specifying the CSS file that styles the controls, or inserting a default value into a child control in New mode.

In fact, if you go back to your code and comment the entire method out, you will notice that it makes no visible difference to how the webpart is displayed on your SharePoint website. Of course, that might be cause I haven’t been specifying and CSS files. Maybe at a later stage we will see this method being used in some other fashion that will make sense. For now, it makes no difference to the usability or appearence of the webparts.

MGR: the Intelogist

About MGR: the Intelogist

SharePoint Server developer, turned Sitefinity developer, turned Angular developer, turned SharePoint Online consultant, turned Unily consultant, turned O365 consultant... Never a dull moment!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.