Programmatically create WebPage with content.

In this post I will explain how you can programmatically create a new WebPage and how you can put some content on the page.

First off all, how to programmatically create a new WebPage?

Use the following code:


After the page-creation works it’s time to put some content on the page.
There is a default webpart (the ContentEditorWebPart) where you can put some Xml in.

Use following code to add content. It can be inserted just after the “pageItem.UpdateOverwriteVersion()” in the above method.


After you implemented all the code you should get a webpage with a webpart that looks like this (in edit-mode):


Leave a Reply

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