Automate Page creation using Feature Receiver

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

//Page Name//
string
pageName=”MKSDemo.aspx”;
string pageTitle=”Demo Title”;

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s