TemplateBuilder

it2022-05-09  26

http://msdn.microsoft.com/zh-cn/vstudio/system.web.ui.templatebuilder_members(VS.85).aspx

   TemplateBuilder 成员 TemplateBuilder 成员

支持在生成模板及其包含的子控件时使用的页分析器。

下表列出了由 TemplateBuilder 类型公开的成员。

 公共构造函数  名称 说明 TemplateBuilder 初始化 TemplateBuilder 类的新实例。 页首  公共属性 (请参见 受保护的属性 )  名称 说明 BindingContainerType  获取此生成器所创建控件的绑定容器的类型。(从 ControlBuilder 继承)ControlType  获取要创建的控件的 Type。(从 ControlBuilder 继承)CurrentFilterResolutionService  获取一个 IFilterResolutionService 对象,在设计器中分析和保持控件时使用该对象管理与设备筛选器相关的服务。(从 ControlBuilder 继承)DeclareType  获取代码生成将用于声明控件的类型。(从 ControlBuilder 继承)HasAspCode  获取一个值,该值指示控件是否包含任何代码块。(从 ControlBuilder 继承)ID  获取或设置要生成的控件的标识符属性。(从 ControlBuilder 继承)Localize  获取一个布尔值,该值指示由此 ControlBuilder 对象所创建的控件是否已本地化。(从 ControlBuilder 继承)NamingContainerType  获取此生成器所创建控件的命名容器的类型。(从 ControlBuilder 继承)ServiceProvider  获取此 ControlBuilder 对象的服务对象。(从 ControlBuilder 继承)TagName  获取要生成的控件的标记名称。(从 ControlBuilder 继承)Text 获取或设置模板的开始和结束标记之间的文本。ThemeResolutionService  获取一个 IThemeResolutionService 对象,该对象用于在设计时管理控件的主题和外观。(从 ControlBuilder 继承) 页首  受保护的属性  名称 说明 FChildrenAsProperties  确定该控件是否有 ChildrenAsProperties 设置为 true 的 ParseChildrenAttribute。(从 ControlBuilder 继承)FIsNonParserAccessor  确定控件是否实现 IParserAccessor 接口。(从 ControlBuilder 继承)InDesigner  返回 ControlBuilder 是否正在设计器中运行。(从 ControlBuilder 继承)InPageTheme  获取一个布尔值,该值指示此 ControlBuilder 对象是否用于生成页主题。(从 ControlBuilder 继承)Parser  获取负责分析控件的 TemplateParser。(从 ControlBuilder 继承)

// (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Permissive License. // See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. // All other rights reserved.

using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Text; using System.Web.UI.WebControls; using System.Web.UI; using System.Web.UI.Design; using System.Web.UI.Design.WebControls;

namespace AjaxControlToolkit {     /// <summary>     /// Simple read-only designer for the Accordion control     /// </summary>     [SuppressMessage("Microsoft.Security", "CA2117:AptcaTypesShouldOnlyExtendAptcaBaseTypes", Justification = "Security handled by base class")]     public class AccordionDesigner : ControlDesigner     {         /// <summary>         /// Reference to the Accordion control we're designing         /// </summary>         private Accordion _accordion;

        /// <summary>         /// Initializes a new instances of the AccordionDesigner class         /// </summary>         [SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]         public AccordionDesigner()         {         }

        /// <summary>         /// Initialize to make sure we're attached to an accordion control         /// </summary>         /// <param name="component">Component</param>         [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Justification = "Assembly is not localized")]         [SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]         public override void Initialize(IComponent component)         {             _accordion = component as Accordion;             if (_accordion == null)                 throw new ArgumentException("Component must be an Accordion control", "component");             base.Initialize(component);         }

        /// <summary>         /// Get the HTML for the Accordion         /// </summary>         /// <returns>HTML design time representation</returns>         [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "controls", Justification = "See code comment below")]         [SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]         public override string GetDesignTimeHtml()         {             // Ensure the controls have been created             ControlCollection controls = _accordion.Controls;

            // Get the base html for the accordion's div             // so that any accordion styles will be applied             StringBuilder html = new StringBuilder();             html.Append(base.GetDesignTimeHtml());

            // Remove the closing div tag so we can insert the HTML             // for all of the panes             html.Remove(html.Length - 6, 6);

            // Add the HTMl for each pane             foreach (AccordionPane pane in _accordion.Panes)             {                 html.Append("<span>");                 string headerCSS = !string.IsNullOrEmpty(pane.HeaderCssClass) ? pane.HeaderCssClass : _accordion.HeaderCssClass;                 html.AppendFormat("<div class=\"{0}\">", headerCSS);                 TemplateBuilder builder = pane.Header as TemplateBuilder;                 if (builder != null)                     html.Append(builder.Text);                 html.Append("</div>");

                string contentCSS = !string.IsNullOrEmpty(pane.ContentCssClass) ? pane.ContentCssClass : _accordion.ContentCssClass;                 html.AppendFormat("<div class=\"{0}\">", contentCSS);                 builder = pane.Content as TemplateBuilder;                 if (builder != null)                     html.Append(builder.Text);                 html.Append("</div>");                 html.Append("</span>");             }

            html.Append("</div>");             return html.ToString();         }     } }

转载于:https://www.cnblogs.com/nanshouyong326/archive/2009/02/21/1395343.html

相关资源:数据结构—成绩单生成器

最新回复(0)