Is there a simple way to add a web part page to a Sharepoint site programmatically, using either the object model or web services? It seems straight-forward to create lists
An alternative solution to the accepted answer from @AlexAngas is to use the NewWebPage method of the SharePoint Foundation RPC Protocol, as suggested here.
private static void CreateWebPartPage(this SPWeb web, SPList list, string pageName, int layoutTemplate)
{
const string newWPPage = "" +
"" +
"" +
"{0} " +
"NewWebPage " +
"New " +
"WebPartPage " +
"{2} " +
"true " +
"{1} " +
" " +
" ";
var newWPPageBatchXml = string.Format(newWPPage, list.ID, pageName, layoutTemplate);
var result = web.ProcessBatchData(newWPPageBatchXml);
}
Usage of the above extension method:
web.CreateWebPartPage(yourList, "NewPage", 2);