/// <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); }
/// <include file='doc\TemplateEditingFrame.uex' path='docs/doc[@for="TemplateEditingFrame.Save"]/*' /> /// <devdoc> /// <para> /// Extracts the current contents for the marked template sections in the live tree, /// and notifies the designer with the updated contents for the individual templates. /// </para> /// </devdoc> public void Save() { try { if (templateElements != null) { object[] editable = new object[1]; for (int i = 0; i < templateNames.Length; i++) { if (templateElements[i] != null) { NativeMethods.IHTMLElement htmlElemTemplate = (NativeMethods.IHTMLElement)templateElements[i]; htmlElemTemplate.GetAttribute("contentEditable", /*lFlags*/ 0, editable); if ((editable[0] != null) && (editable[0] is string) && (String.Compare((string)editable[0], "true", true, CultureInfo.InvariantCulture) == 0)) { string templateContent = htmlElemTemplate.GetInnerHTML(); owner.SetTemplateContent(this, templateNames[i], templateContent); } } } } } catch (Exception ex) { Debug.Fail(ex.ToString()); } }
// Convenience method for checking if the specified element has a design time lock. private bool IsElementLocked(NativeMethods.IHTMLElement element) { object[] attribute = new object[1]; element.GetAttribute(DesignTimeLockAttribute, 0, attribute); if (attribute[0] == null) { NativeMethods.IHTMLStyle style = element.GetStyle(); attribute[0] = style.GetAttribute(DesignTimeLockAttribute, 0); } return((attribute[0] != null) && (attribute[0] is string)); }