Hide

YetaWF.Core Package Documentation

Display
Print

YetaWF.Core.Components.YetaWFComponentExtender.ForLabelAsync Method

Renders an HTML <label> with the specified attributes.

Class: YetaWF.Core.Components.YetaWFComponentExtender
Namespace: YetaWF.Core.Components
Assembly: YetaWF.Core

Syntax

public static Task<string> ForLabelAsync(
    this YHtmlHelper htmlHelper,
    object container,
    string propertyName,
    bool ShowVariable = false,
    bool SuppressIfEmpty = true,
    object? HtmlAttributes = null );

Parameters

htmlHelper

The HtmlHelper instance.

container

The container model where the specified property propertyName is located.

propertyName

The property name for which a label is rendered.

ShowVariable

Defines whether the property name is shown as part of the description (tooltip).

SuppressIfEmpty

Defines whether an empty string should be generated if the label caption is empty (true), otherwise the label is always generated even if there is no caption (false).

HtmlAttributes

A collection of attributes.

Return Value

Returns HTML with the rendered <label>.

Remarks

The HtmlAttributes may contain a "Description" entry which is used as the label's description (tooltip). If none is provided, the property's DescriptionAttribute is used instead. If this isn't found, the label does not have a description or tooltip.

The HtmlAttributes may contain a "Caption" entry which is used as the label's caption (text). If none is provided, the container model's "propertyName_Label" property is retrieved and used as label caption. If none is provided, the property's CaptionAttribute is used instead. If this isn't found, the label does not have a caption (text).

If the container model's property propertyName has a HelpLinkAttribute, the label has a clickable help icon.

See Also YetaWF.Core.Components.YetaWFComponentExtender ClassYetaWF.Core Overview