Page Tag Helpers and slots

Add your own content inside a page of the admin panel

StellarAdmin renders the content of each resource page with a Tag Helper. When you override a page, your view uses the Tag Helper for the page, and passes it the view's model:

Tag HelperPageModel
<sa-index-page>IndexResourceIndexPageViewModel<TResource> or IResourceIndexPageViewModel
<sa-form-page>Create and editResourceFormPageViewModel
<sa-view-page>ViewResourceViewPageViewModel
Areas/StellarAdmin/Views/bookings/View.cshtml
@model ResourceViewPageViewModel
@{
    ViewData["Title"] = Model.Title;
}

<sa-view-page model="Model" />

Adding content with slots

A slot is a place inside the page where you can add your own content, such as a button in the page's header. To fill a slot, put an <sa-slot-content> element with the slot's name inside the Tag Helper.

The example below adds an Invoice button after the Edit button of the bookings view page, and a card below the fields:

Areas/StellarAdmin/Views/bookings/View.cshtml
@model ResourceViewPageViewModel
@{
    ViewData["Title"] = Model.Title;
}

<sa-view-page model="Model">
    <sa-slot-content name="post-page-actions">
        <sa-link-button href="@($"/invoices/{Model.EntityId}")" variant="ButtonVariant.Outline">
            Invoice
        </sa-link-button>
    </sa-slot-content>
    <sa-slot-content name="post-view-fields">
        <sa-card>
            <sa-card-content>Payment history goes here.</sa-card-content>
        </sa-card>
    </sa-slot-content>
</sa-view-page>

The Tag Helper renders only the content of its <sa-slot-content> elements. Anything else you put inside it isn't rendered. To add content outside the slots, put it before or after the Tag Helper.

Each Tag Helper has the following slots:

Tag HelperSlotWhere the content goes
<sa-index-page>pre-page-actionsIn the header, before the Create button
post-page-actionsIn the header, after the Create button
<sa-form-page>pre-form-fieldsAbove the fields
post-form-fieldsBelow the fields
form-leading-actionsIn the header, at the start of the form's buttons
pre-form-actionsIn the header, before the Cancel button
post-form-actionsIn the header, after the submit button
<sa-view-page>pre-page-actionsIn the header, at the start of the page's buttons
post-page-actionsIn the header, after the Edit button
pre-view-fieldsAbove the fields
post-view-fieldsBelow the fields

The edit page has no Delete button. To add one, see adding a Delete button to the edit page.

The index page has no slot between its header and the grid. To add content there, put it above the Tag Helper, as in the example on overriding pages.

Replacing the content of the page

To replace the content that a Tag Helper renders, set its view attribute to the name of your own partial view, or to its path from your app's root. The partial view receives the Tag Helper's model, and renders the content of a slot where it contains an <sa-slot-outlet> element with the slot's name:

<sa-slot-outlet name="post-page-actions" />

On this page