开发者

Publish Page along with content

I have created a PageLayout associated a content type with codebehind which has a button.When button is clicked it checks in and publishes the page.The functionality works but the problem 开发者_Python百科the content is not getting saved on the page.

But when I click the check in button (out of the Box) on top of the page it saves the content.

Here is the code:

SPList pagesList = SPContext.Current.Web.Lists["Pages"];
SPFolder folder = pagesList.ParentWeb.GetFolder(SPContext.Current.Web.Url + "/" + pagesList + "/" + "PhlyEventsPages");
SPListItemCollection itemCol = pagesList.Items;
foreach (SPListItem item in itemCol)
{
    if (item["FileLeafRef"].ToString()==getCurrentUrl())
    {
        if (item.File.CheckOutStatus == SPFile.SPCheckOutStatus.LongTerm)
        {                             
            item.File.Update();
            pagesList.Update();
            item.File.CheckIn("Page Created");
            item.File.Publish("Published");
            break;
        }
}


Well, your code grabs the OLD copy of the item. You need to call Update() on the SPContext.Current.ListItem, that's where the POST data gets put.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜