/// <summary> /// Expands this instance. /// </summary> public void Expand() { if (Placeholders != null) { foreach (var placeHolderName in Placeholders) { global::Sitecore.Web.UI.WebControls.Placeholder holder = new global::Sitecore.Web.UI.WebControls.Placeholder(); holder.Key = placeHolderName.ToLower(); this.Controls.Add(holder); } } this.Controls.Cast <Control>().Where(x => x is global::Sitecore.Layouts.IExpandable) .Cast <global::Sitecore.Layouts.IExpandable>().ToList().ForEach(x => x.Expand()); }
/// <summary> /// Placeholders the specified key. /// </summary> /// <param name="key">The key.</param> /// <returns>IEncodedString.</returns> public IEncodedString Placeholder(string key) { key = key.ToLower(); var placeHolder = Placeholders.FirstOrDefault(x => x.Key == key); if (placeHolder == null) { placeHolder = new global::Sitecore.Web.UI.WebControls.Placeholder { Key = key } } ; ParentControl.Controls.Add(placeHolder); var sb = new StringBuilder(); placeHolder.RenderControl(new HtmlTextWriter(new StringWriter(sb))); return(Raw(sb.ToString())); }