本文整理匯總了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);
}