Default Section attribute

API Reference: DefaultSectionAttribute Class

The DefaultSectionAttribute can be applied to page and content models. The attribute specifies the section in the user interface that properties of this model will be grouped in when they do not have a section specified explicitly. This reduces the need to apply SectionAttribute attributes on each individual property.

Usage

Decorate the page or content model class with the DefaultSectionAttribute. Pass the section display name in the constructor. All properties without a section defined will be will be grouped in this default section in the user interface. The attribute is not inherited, so if a default section is specified on a base class, it will not be automatically specified on derived classes.

Default Convention

If DefaultSectionAttribute is not specified on a model, all properties that do not have a section defined will be grouped in a section named Content.

Example

[DefaultSection("Basic Properties")]
public class SamplePage: IPageModel
{
    // This property will appear in a section named 'SEO'.
    [Section("SEO")]
    public string Description { get; set; }

    // This property will appear in the default section named 'Basic Properties'.
    public string Summary { get; set; }

    // By convention, content model properties will appear in their own section ('Footer' in this case).
    public FooterContent Footer { get; set; }

    // Unless a section is specified explicitly. This property will be in the same section with the 'Description' property.
    [Section("SEO")]
    public SeoContent Seo { get; set; }
}