Search This Blog

Monday, March 28, 2011

Error:- "Column 'Page Content' does not exist. It may have been deleted by another user."

In a scenario I have to write the content in the “page content area” with some formatting. Using UI we can do this very easily by just clicking on “Edit as HTML” link and writing the HTML code in the editor.
Programmatically we can do this using the following code snippet:
PublishingPage objPublishingPage;
PublishingWeb objPublishingWeb;
String PageUrl =http://...;
String PageName =”XYZ.aspx”;
objPublishingWeb = PublishingWeb.GetPublishingWeb(SPWebObject);
objPublishingPage = objPublishingWeb.GetPublishingPage(PageUrl + "/" + PageName);
if (objPublishingPage != null)
{
objPublishingPage.CheckOut();
objPublishingPage.ListItem["Page Content"]=PageContent;
objPublishingPage.ListItem.Update();
}
This works fine till you are not using the multilingual feature. But I have to also publish the content in its locale language in the multilingual page, in which the above code fails and give the error “Column 'Page Content' does not exist. It may have been deleted by another user. ”. In Multilingual page the column “Page Content” changes its language to its local so it’s hard to find the column instead of this we can use the following code snippet:
PublishingPage objPublishingPage;
PublishingWeb objPublishingWeb;
String PageUrl =http://...;
String PageName =”XYZ.aspx”;
objPublishingWeb = PublishingWeb.GetPublishingWeb(SPWebObject);
objPublishingPage = objPublishingWeb.GetPublishingPage(PageUrl + "/" + PageName);
if (objPublishingPage != null)
{
objPublishingPage.CheckOut();
objPublishingPage.ListItem["PublishingPageContent"]=PageContent;
objPublishingPage.ListItem.Update();
}

No comments:

Post a Comment