/// <include file='doc\TemplateEditingService.uex' path='docs/doc[@for="TemplateEditingService.GetContainingTemplateName"]/*' /> public string GetContainingTemplateName(Control control) { string containingTemplateName = String.Empty; HtmlControlDesigner designer = (HtmlControlDesigner)designerHost.GetDesigner(control); if (designer != null) { IHtmlControlDesignerBehavior behavior = designer.Behavior; NativeMethods.IHTMLElement htmlElement = (NativeMethods.IHTMLElement)behavior.DesignTimeElement; if (htmlElement != null) { object[] varTemplateName = new Object[1]; NativeMethods.IHTMLElement htmlelemParentNext; NativeMethods.IHTMLElement htmlelemParentCur = htmlElement.GetParentElement(); while (htmlelemParentCur != null) { htmlelemParentCur.GetAttribute("templatename", /*lFlags*/ 0, varTemplateName); if (varTemplateName[0] != null && varTemplateName[0].GetType() == typeof(string)) { containingTemplateName = varTemplateName[0].ToString(); break; } htmlelemParentNext = htmlelemParentCur.GetParentElement(); htmlelemParentCur = htmlelemParentNext; } } } return(containingTemplateName); }
public ArrayList GetParentHierarchy(object o) { NativeMethods.IHTMLElement current = this.GetHtmlElement(o); if (current == null) { return(null); } string tagName = current.GetTagName().ToLower(); if (tagName.Equals("body")) { return(null); } ArrayList ancestors = new ArrayList(); current = current.GetParentElement(); while ((current != null) && (current.GetTagName().ToLower().Equals("body") == false)) { HtmlElement element = new HtmlElement(current, this.control); if (IsSelectableElement(element)) { ancestors.Add(element); } current = current.GetParentElement(); } // Don't add the body tag to the hierarchy if we aren't in full document mode if (current != null) { HtmlElement element = new HtmlElement(current, this.control); if (IsSelectableElement(element)) { ancestors.Add(element); } } return(ancestors); }