0

I have created a custom Home page as well as another custom page which are being added to the pages library in a publishing portal site. The pages are successfully being added, however they are not published, they are in pending status. I would like to have them both published once the feature is activated, how can i go about doing this?

Other info: The pages are being added via a module.Is there a way i can find the pages and activate in an event receiver? If so how?

1 Answer 1

1

Well you can try something like:

SPList lstPages = web.Lists.TryGetList("Pages");
if (lstPages != null)
{
    SPListItemCollection pagesColl = lstPages.Items;
    foreach (SPListItem page in pagesColl)
    {
        page.File.Publish("Page published by Feature Event Receiver");
    }
}

If you want to get only those pages which you have created, you can use SPQuery to filter List Items or in the loop you can put condition like if (page["Title"] == "Your Page Title")

Let me know if you need help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.