Section attribute

API Reference: SectionAttribute Class

The SectionAttribute can be applied to page and content model properties. The attribute specifies the section in the user interface that this property will be grouped in. This allows you to group properties in a user friendly way in the user interface, while enabling you to structure your model classes in a different way.

Usage

Decorate the property class with the SectionAttribute. Pass the section display name in the constructor. All properties with the same section name will be grouped in the same section in the user interface. You can combine this with the SortOrderAttribute to set the order of different properties within a section.

Default Convention

If SectionAttribute is not specified on a property, the property will be grouped in the default section set on the model class with the DefaultSectionAttribute. If this is also not set, the property 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; }
}