EPiWiki.se  - EPiServer notes shared with others
 

get current page in the control adapter

[Edit]
Sample code how to get current page in a custom EPiServer control adapter.

public class PropertyPageReferenceControlAdapeter : PropertyDataControlAdapter
    {
        protected bool TryGetCurrentPage(out PageData currentPage)
        {
            currentPage = null;
            var pageLinkProp = Properties[Const.Property.PageLink]
                                  as PropertyPageReference;

            if (pageLinkProp == null)
            {
                return false;
            }

            currentPage = DataFactory.Instance.GetPage(
                              (PageReference)pageLinkProp.Value);

            return currentPage != null;
        }
Version author:
Mattias Lövström

EPiServer version

All