/// <summary>Adds a content part to a containing control. Override this method to adapt how a part is added to a parent.</summary> /// <param name="item"></param> /// <param name="container"></param> /// <returns></returns> public virtual Control AddTo(ContentItem item, Control container) { IAddablePart addablePart = item as IAddablePart; if (addablePart != null) { return(addablePart.AddTo(container)); } var renderer = item as Rendering.IContentRenderer ?? RendererSelector.ResolveRenderer(item.GetContentType()); if (renderer != null) { var rendererControl = new ContentRendererControl(renderer, new Rendering.ContentRenderingContext { Content = item, Container = container }); container.Controls.Add(rendererControl); return(rendererControl); } string templateUrl = GetTemplateUrl(item); if (string.IsNullOrEmpty(templateUrl)) { return(null); } return(AddUserControl(Url.ResolveTokens(templateUrl), container, item)); }
/// <summary>Adds a content part to a containing control. Override this method to adapt how a part is added to a parent.</summary> /// <param name="item"></param> /// <param name="container"></param> /// <returns></returns> public virtual Control AddTo(ContentItem item, Control container) { IAddablePart addablePart = item as IAddablePart; if (addablePart != null) { return(addablePart.AddTo(container)); } string templateUrl = GetTemplateUrl(item); if (string.IsNullOrEmpty(templateUrl)) { return(null); } return(ItemUtility.AddUserControl(Url.ResolveTokens(templateUrl), container, item)); }