本文整理汇总了C#中System.Web.UI.HtmlTextWriter.GetStyleKey方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.GetStyleKey方法的具体用法?C# HtmlTextWriter.GetStyleKey怎么用?C# HtmlTextWriter.GetStyleKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.GetStyleKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderBeginTag
// Override the RenderBeginTag method to check whether
// the tagKey parameter is set to a <label> element
// or a <font> element.
public override void RenderBeginTag(HtmlTextWriterTag tagKey)
{
// If the tagKey parameter is set to a <label> element
// but a color attribute is not defined on the element,
// the AddStyleAttribute method adds a color attribute
// and sets it to red.
if (tagKey == HtmlTextWriterTag.Label)
{
if (!IsStyleAttributeDefined(HtmlTextWriterStyle.Color))
{
AddStyleAttribute(GetStyleKey("color"), "red");
}
}
// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point.
if (tagKey == HtmlTextWriterTag.Font)
{
if (!IsAttributeDefined(HtmlTextWriterAttribute.Size))
{
AddAttribute(GetAttributeKey("size"), "30pt");
}
}
// Call the base class's RenderBeginTag method
// to ensure that this custom MarkupTextWriter
// includes functionality for all other markup elements.
base.RenderBeginTag(tagKey);
}