TemplateBuilder

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 设置为 trueParseChildrenAttribute。(从 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();
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值