本文整理汇总了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);
}
示例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");
}
}
示例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);
}
示例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);
}