Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How I can find a specific publishing page inside PublishingPageCollection and get its HTML source

$
0
0

I am working on an event receiver inside my Enterprise wiki site collection inside SharePoint 2013. Now inside my event receiver I am trying to do the following:-

1. Find specific wiki page (by title, Name or UL).

2. For this page get its HTML Source code. Similar to the HTML source code I get when I edit a wiki page, click on “Edit Source” button.

Now I have the following code inside my event receiver, where I am able to get all the wiki pages, but seems trying to get a wiki page by title or by name is not working using the indexer,, as the (PublishingPage pp) variable will always be null..

public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            SPWeb spCurrentSite = properties.OpenWeb();
            if (properties.List.Title.ToLower() == "customers")
            {



                PublishingSite pSite = new PublishingSite(properties.Site);
                SPContentType ctype = pSite.ContentTypes["Enterprise Wiki Page"];
                PageLayoutCollection pageLayouts = pSite.GetPageLayouts(ctype, true);
                PageLayout pageLayout = pageLayouts["EnterpriseWiki.aspx"];
                PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(properties.Web);

                PublishingPageCollection pPages = pWeb.GetPublishingPages();
                //
                int t = pPages.Count;
                PublishingPage pp = pPages["Test - Main"];// I have a wiki page with title= “Test – Main”

so can anyone adivce if there is a way to get a specific wiki page by title,name or url and for this wiki page to get its HTML source?

Thanks


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>