API Reference: PlaceholderAttribute Class

The PlaceholderAttribute can be applied to content model properties. The attribute specifies a placeholder to be displayed in the field editor as long as no value has been set for the property.

The attribute is supported by several property editors, including (multiline) textbox, rich text, select list, and numeric editors. Applying the attribute to a property with an editor that doesn't support PlaceholderAttribute has no effect.

Usage

Decorate the model property with the PlaceholderAttribute. Pass the placeholder text in the attribute constructor.

Example

public class SampleContent: IContentType
{
    // Sets a placeholder on a single-line textbox
    [Placeholder("Descriptive title")]
    public string Title { get; set; }

    // Sets a placeholder on a rich text editor
    [Placeholder("Start typing...")]
    public HtmlString IntroText { get; set; }

    // Sets a placeholder on a select list (dropdown)
    [SelectList("option1|Option 1", "option2|Option 2", "option3|Option3")
    [Placeholder("Select an option")]
    public string MyOptions { get; set; }

    // ...
}