Content Inclusion Web Part

Simply put the content inclusion web part reads a text document from a document library and outputs the files contents to the web part page. The content inclusion web part allows you to, for example, create one JavaScript file that is used across many pages and modify just the one file, causing the changes to take affect on all the pages it is used in.

Let’s say you have some JavaScript code that you need to put on several pages of your SharePoint site. Normally you would have to add a content editor web part to each page and copy and paste the JavaScript into the content editor web part on each page. If you ever need to change that JavaScript you have to go back and repeat the process on all of the pages. With the content inclusion web part you are essentially creating a content editor web part that links back to the contents of a file stored in a document library. This way when you make changes to your JavaScript you just need to modify the single instance of the file that is stored in the document library.

Below is the code for the content inclusion web part. Some improvements that could be made to this code are better error checking and the ability to access document libraries from sites other than the web parts current context. I would love to hear feedback/ideas any one has about this web part. 

Download Source Code

- Mark