当前位置: 首页>>代码示例>>C#>>正文


C# IHtmlWriter.AddStyleAttribute方法代码示例

本文整理汇总了C#中IHtmlWriter.AddStyleAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlWriter.AddStyleAttribute方法的具体用法?C# IHtmlWriter.AddStyleAttribute怎么用?C# IHtmlWriter.AddStyleAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHtmlWriter的用法示例。


在下文中一共展示了IHtmlWriter.AddStyleAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddAttributesToRender

        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!RenderOnServer)
            {
                writer.AddKnockoutDataBind("visible", $"!({ GetForeachDataBindJavascriptExpression() }).length");

                if (DataSource != null && GetIEnumerableFromDataSource(DataSource).OfType<object>().Any())
                {
                    writer.AddStyleAttribute("display", "none");
                }
            }

            base.AddAttributesToRender(writer, context);
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:14,代码来源:EmptyData.cs

示例2: AddVisibleAttributeOrBinding

 /// <summary>
 /// Adds the corresponding attribute or binding for the Visible property.
 /// </summary>
 protected virtual void AddVisibleAttributeOrBinding(IHtmlWriter writer)
 {
     writer.AddKnockoutDataBind("visible", this, VisibleProperty, renderEvenInServerRenderingMode: true);
     if (GetValue(VisibleProperty) as bool? == false)
     {
         writer.AddStyleAttribute("display", "none");
     }
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:11,代码来源:HtmlGenericControl.cs

示例3: AddAttributesToRender

        /// <summary>
        /// Adds all attributes that should be added to the control begin tag.
        /// </summary>
        protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
        {
            // render hard-coded HTML attributes
            foreach (var attribute in Attributes.Where(a => a.Value is string || a.Value == null))
            {
                writer.AddAttribute(attribute.Key, (string)attribute.Value, true);
            }

            // render binding HTML attributes
            var propertyValuePairs = Attributes.Where(a => a.Value is ValueBindingExpression)
                .Select(a => new KeyValuePair<string, ValueBindingExpression>(a.Key, (ValueBindingExpression)a.Value)).ToList();
            if (propertyValuePairs.Any())
            {
                writer.AddKnockoutDataBind("attr", propertyValuePairs, this, null);
            }

            // handle Visible property
            writer.AddKnockoutDataBind("visible", this, VisibleProperty, () =>
            {
                if (!Visible)
                {
                    writer.AddStyleAttribute("display", "none");
                }
            });

            // handle Text property
            writer.AddKnockoutDataBind("text", this, InnerTextProperty, () =>
            {
                // inner Text is rendered as attribute only if contains binding
                // otherwise it is rendered directly as encoded content
            });

            // hadle Id property
            AddControlIdAttribute(writer);

            base.AddAttributesToRender(writer, context);
        }
开发者ID:adamjez,项目名称:dotvvm,代码行数:40,代码来源:HtmlGenericControl.cs

示例4: AddAttributesToRender

        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!context.IsInPartialRenderingMode)
            {
                writer.AddStyleAttribute("display", "none");
            }
            writer.AddKnockoutDataBind("if", "dotvvm.isSpaReady");

            if (!string.IsNullOrEmpty(DefaultRouteName))
            {
                var route = context.Configuration.RouteTable[DefaultRouteName];
                if (route.ParameterNames.Any())
                {
                    throw new DotvvmControlException(this, $"The route '{DefaultRouteName}' specified in SpaContentPlaceHolder DefaultRouteName property cannot contain route parameters!");
                }
                writer.AddAttribute(HostingConstants.SpaContentPlaceHolderDefaultRouteDataAttributeName, route.Url);
            }
            base.AddAttributesToRender(writer, context);
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:19,代码来源:SpaContentPlaceHolder.cs


注:本文中的IHtmlWriter.AddStyleAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。