Html32TextWriter.SupportsBold Property

Definition

Gets or sets a Boolean value indicating whether the requesting device supports bold HTML text. Use the SupportsBold property to conditionally render bold text to the Html32TextWriter output stream.

public bool SupportsBold { get; set; }

Property Value

true if the requesting device supports bold text; otherwise, false. The default is true.

Examples

The following code example demonstrates how to override the RenderBeforeContent and RenderAfterContent methods. Each override checks whether a Label element is being rendered, and then uses the SupportsBold method to check whether the requesting device can display bold formatting. If the device supports bold formatting, the RenderBeforeContent method writes the opening tag of a b element and the RenderAfterContent method writes its closing tag. If the device does not support bold formatting, the RenderBeforeContent method writes the opening tag of a Font element with a color attribute set to the hexadecimal value for red, and the RenderAfterContent method writes the closing tag.

This code example is part of a larger example provided for the Html32TextWriter class.

// Override the RenderBeforeContent method to render
// styles before rendering the content of a <th> element.
protected override string RenderBeforeContent()
{
    // Check the TagKey property. If its value is
    // HtmlTextWriterTag.TH, check the value of the 
    // SupportsBold property. If true, return the
    // opening tag of a <b> element; otherwise, render
    // the opening tag of a <font> element with a color
    // attribute set to the hexadecimal value for red.
    if (TagKey == HtmlTextWriterTag.Th)
    {
        if (SupportsBold)
            return "<b>";
        else
            return "<font color=\"FF0000\">";
    }

    // Check whether the element being rendered
    // is an <H4> element. If it is, check the 
    // value of the SupportsItalic property.
    // If true, render the opening tag of the <i> element
    // prior to the <H4> element's content; otherwise, 
    // render the opening tag of a <font> element 
    // with a color attribute set to the hexadecimal
    // value for navy blue.
    if (TagKey == HtmlTextWriterTag.H4)
    {
        if (SupportsItalic)
            return "<i>";
        else
            return "<font color=\"000080\">";
    }
    // Call the base method.
    return base.RenderBeforeContent();
}

Applies to

Өнім Нұсқалар
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also