Customizing the content of the publication page programmatically

I want to know how to set the contents of a publication page using code (MOSS 2007).
This is how I created the page:

PublishingPage page = publishingWeb.GetPublishingPages().Add("MyPage.aspx", pageLayout); SPFile pageFile = page.ListItem.File; page.Title = "My Page"; page.Update(); 

But my attempts to establish its content did not work.

+4
source share
2 answers

I don’t know if he could ok answer my own question, but after reflecting the Sharepoint code, I managed to find a way to set the content of the page:

 string content = "Welcome to <strong>My Page</strong>"; page.ListItem[FieldId.PublishingPageContent] = content; 
+5
source

Personally, I think you are mistaken.

Why not instead wrap your code in a function that might even contain a physical aspx file, but the contents of the page are optional.

Then you can add the page to the documented library of standard pages that comes with SharePoint when this feature is activated, all of this can be done using CAML (XML), and you won’t need to enter the code into the function receiver.

+2
source

All Articles