private static void BuildServerSidePage(Control nativeRoot, PageCompositionElement pp)
        {
            foreach (var kvp in pp.PlaceHolders)
            {
                var placeHolder = kvp.Value;

                Control contentPlaceHolder = nativeRoot.FindControl(placeHolder.Id);

                if (contentPlaceHolder == null)
                {
                    throw new Exception("Placeholder " + placeHolder.Id + " does not exist.");
                }

                foreach (var placedRendering in placeHolder.Renderings)
                {
                    if (placedRendering is WebFormsControlPageCompositionElement)
                    {
                        WebFormsControlPageCompositionElement webFormsCompositionElement = ((WebFormsControlPageCompositionElement)placedRendering);
                        AddRenderHtmlDirective(webFormsCompositionElement, contentPlaceHolder);

                        var control = webFormsCompositionElement.GetControl();
                        BuildServerSidePage(control, placedRendering);
                    }
                    else
                    {
                        var directive = AddDoNotRenderDirective(placedRendering, contentPlaceHolder);
                        BuildServerSidePage(directive, placedRendering);
                    }
                }
            }
        }
        private static RenderHtmlWriterDirective AddRenderHtmlDirective(WebFormsControlPageCompositionElement placedRendering, Control contentPlaceHolder)
        {
            var compositionElement = (WebFormsControlPageCompositionElement)placedRendering;
            var wrapped            = new RenderHtmlWriterDirective(compositionElement);

            contentPlaceHolder.Controls.Add(wrapped);
            wrapped.Initialize();
            return(wrapped);
        }
 public RenderHtmlWriterDirective(WebFormsControlPageCompositionElement pp)
 {
     _pp = pp;
 }