Automate Page creation using Feature Receiver

1. Create SPWeb web object
2. Create PublishingPageCollection publishingPages object
3. Create PageLayout pageLayout object

//Page Name//
string pageTitle=”Demo Title”;

web.AllowUnsafeUpdates = true;
PublishingPage currentPage = publishingPages.Add(pageName, pageLayout);
currentPage.Title = pageTitle;
currentPage.CheckIn(“System Created : ” + pageName);
currentPage.ListItem.File.Publish(“System Published : ” + pageName);
currentPage.ListItem.File.Approve(“System Approved : ” + pageName);
web.AllowUnsafeUpdates = false;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s