AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. Developing websites
  3. Developing Xperience applications using ASP.NET Core
  4. Reference - Xperience Tag Helpers

Reference - Xperience Tag Helpers


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

This page serves as a reference of all ASP.NET Core Tag Helpers⁠ (opens in a new tab) provided by the Xperience API.

Adding Tag Helpers to views

You can add individual Tag Helpers to your views via the @addTagHelper directive. Specify the fully qualified name of the Tag Helper class and the name of the assembly where it is located (both provided in the corresponding sections below). Alternatively, you can use the '*' wildcard to include all Tag Helpers matching a specified pattern.

XML
@* Adds all Tag Helpers from the Kentico.Content.Web.Mvc assembly to the view *@
@addTagHelper *, Kentico.Content.Web.Mvc

@* Adds the form zone Tag Helper to the view *@
@addTagHelper Kentico.Content.Web.Mvc.FormZoneTagHelper, Kentico.Content.Web.Mvc

Add the Tag Helpers in relevant _ViewImports.cshtml⁠ (opens in a new tab) files to make them available in all related views automatically.

Tag Helpers – Page builder

Page builder scripts

Fully qualified name: Kentico.Content.Web.Mvc.PageBuilderScriptsTagHelper

Assembly name: Kentico.Content.Web.Mvc

Renders markup that includes scripts required by the page builder feature. Serves as an alternative to the HtmlHelper.Kentico().PageBuilderScripts extension method.

The Tag Helper includes scripts used in the system's editing interface, as well as those of individual page builder components (widgets, sections, inline property editors, page templates). See the linked documentation to learn how to correctly add custom scripts for your own components.

XML
@addTagHelper Kentico.Content.Web.Mvc.PageBuilderScriptsTagHelper, Kentico.Content.Web.Mvc

<page-builder-scripts />

Page builder styles

Fully qualified name: Kentico.Content.Web.Mvc.PageBuilderStylesTagHelper

Assembly name: Kentico.Content.Web.Mvc

Renders markup that includes style sheets required by the page builder feature. Serves as an alternative to the HtmlHelper.Kentico().PageBuilderStyles extension method.

The Tag Helper includes style sheets used in the system's editing interface, as well as those of individual page builder components (widgets, sections, inline property editors, page templates). See the linked documentation to learn how to correctly add custom style sheets for your own components.

XML
@addTagHelper Kentico.Content.Web.Mvc.PageBuilderStylesTagHelper, Kentico.Content.Web.Mvc

<page-builder-styles />

Editable area

Fully qualified name: Kentico.Content.Web.Mvc.EditableAreaTagHelper

Assembly name: Kentico.Content.Web.Mvc

Marks a location where a page builder editable area is to be rendered when editing the page via the administration interface. Serves as an alternative to the HtmlHelper.Kentico().EditableAreaAsync extension method.

The helper has the following required attributes:

  • area-identifier– identifier of the area unique within the context of the given page.
XML
@addTagHelper Kentico.Content.Web.Mvc.EditableAreaTagHelper, Kentico.Content.Web.Mvc

<editable-area area-identifier="areaSimple" />

Optionally, you can pass an EditableAreaOptions object via the area-options attribute to further configure the area. See Creating pages with editable areas for details.

XML
@addTagHelper Kentico.Content.Web.Mvc.EditableAreaTagHelper, Kentico.Content.Web.Mvc
@using Kentico.PageBuilder.Web.Mvc

@{
    var options = new EditableAreaOptions
    {
        AllowedWidgets = new[] { "LearningKit.Widgets.NumberWidget",
                                 "LearningKit.Widgets.SomeOtherWidget" },
        AllowedSections = AllowedComponents.ALL
    };
}

<editable-area area-identifier="areaConfigured" area-options="options" />

Alternatively, you can pass each property of the EditableAreaOptions object as an individual attribute:

  • area-options-allowed-sections – a list of section identifiers that can be added to the area. If left empty, all sections are allowed.
  • area-options-allowed-widgets – a list of widget identifiers that can be added to the area. If left empty, all widgets are allowed.
  • area-options-default-section-identifier – identifier of the default section for the area.
  • allow-widget-output-cache – indicates whether the output of individual widgets placed into the area can be cached. This value is combined with the AllowCache property of widgets (specified during widget registration) to determine whether output caching is enabled for each widget instance contained within the area. The default value is false.
  • widget-output-cache-expires-on – a DateTimeOffset value that sets the absolute expiration date for cached content.
  • widget-output-cache-expires-after – a TimeSpan value that sets the length of time from the first request time to cache the contents.
  • widget-output-cache-expires-sliding – a TimeSpan value that defines a sliding window of expiration for the cached content. Content not accessed within the specified time frame gets evicted.

Note that if you both pass the options object and specify some parameters directly via attributes, the parameters specified via attributes take precedence (i.e., override the corresponding properties of the options object).

Cache configuration examples

The caching configuration options are modeled after and behave identically to the Cache tag helper⁠ (opens in a new tab) provided by ASP.NET Core:

XML
@* widget-output-cache-expires-on *@
@* Sets the cached entry to expire on 5:02 PM on January 29, 2025. If the specified date is in the past, nothing gets cached. *@
<editable-area area-identifier="editableArea" area-widget-output-cache="true" widget-output-cache-expires-on="@new DateTime(2025,1,29,17,02,0)" />

@* widget-output-cache-expires-after *@
@* Contents are evicted after five minutes and cached again on subsequent requests. *@
<editable-area area-identifier="editableArea" area-widget-output-cache="true" widget-output-cache-expires-after="@TimeSpan.FromSeconds(300)" />

@* widget-output-cache-expires-sliding *@
@* Cached content is evicted if not accessed again within 120 seconds of the initial request. *@
<editable-area area-identifier="editableArea" area-widget-output-cache="true" widget-output-cache-expires-sliding="@TimeSpan.FromSeconds(120)" />

Widget zone

Fully qualified name: Kentico.Content.Web.Mvc.WidgetZoneTagHelper

Assembly name: Kentico.Content.Web.Mvc

Marks a location where widgets can be placed within a page builder section. Serves as an alternative to the HtmlHelper.Kentico().WidgetZoneAsync extension method.

Every section must contain at least one widget zone – sections without widget zones are not supported.

XML
@addTagHelper Kentico.Content.Web.Mvc.WidgetZoneTagHelper, Kentico.Content.Web.Mvc

<widget-zone />

The helper also has the following optional attributes:

  • zone-name – identifier of the zone used when changing the type of the zone in the page builder.
  • allowed-widgets – a list of widget identifiers that can be added to the zone. If left empty, all widgets are allowed.
XML
@{
    var widgetsWhitelist = new[] { Kentico.Content.Web.Mvc.SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER,
                                   "LearningKit.Widgets.NumberWidget",
                                   "LearningKit.Widgets.SomeOtherWidget" };
}

<widget-zone zone-name="main-zone" allowed-widgets="widgetsWhitelist" />

Page data

Fully qualified name: Kentico.Content.Web.Mvc.WidgetZoneTagHelper

Assembly name: Kentico.Content.Web.Mvc

Renders an invisible form field that includes contextual information about the page. Necessary when developing components that use POST actions. Serves as an alternative to the HtmlHelper.Kentico().PageData extension method.

XML
@addTagHelper Kentico.Content.Web.Mvc.PageDataTagHelper, Kentico.Content.Web.Mvc

<form asp-controller="Controller" asp-action="HandlePost" id="form">

    ...

    <page-data />

    <input type="submit" value="Submit" />
</form>

Component properties data

Fully qualified name: Kentico.Content.Web.Mvc.ComponentPropertiesDataTagHelper

Assembly name: Kentico.Content.Web.Mvc

Used to persist properties of the currently rendered component for POST actions. Server as an alternative to the HtmlHelper.Kentico().ComponentPropertiesData extension method.

XML
@addTagHelper Kentico.Content.Web.Mvc.ComponentPropertiesDataTagHelper, Kentico.Content.Web.Mvc

<form asp-controller="Controller" asp-action="HandlePost" id="form">

    ...

    <component-properties-data />

    <input type="submit" value="Submit" />
</form>

Stand-alone widget

Fully qualified name: Kentico.Content.Web.Mvc.StandaloneWidgetTagHelper

Assembly name: Kentico.Content.Web.Mvc

Renders a specified widget directly. Serves as an alternative to the HtmlHelper.Kentico().RenderStandaloneWidget extension method. See Rendering widgets directly.

The helper has the following attributes:

  • widget-type-identifier– the string identifier under which the widget was registered.
  • (Optional) widget-properties – IWidgetProperties object representing the widget's properties . Create an instance of the appropriate property model class and set any required values.
XML
@addTagHelper Kentico.Content.Web.Mvc.StandaloneWidgetTagHelper, Kentico.Content.Web.Mvc
@using Kentico.Forms.Web.Mvc.Widgets
@using Kentico.Content.Web.Mvc

@{
    var widgetProperties = new FormWidgetProperties()
    {
        SelectedForm = "FormCodeName"
    };
}

@* Renders the system's default Form widget *@
<standalone-widget widget-type-identifier="@SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER" widget-properties="widgetProperties" />

Nested widget

Fully qualified name: Kentico.Content.Web.Mvc.NestedWidgetTagHelper

Assembly name: Kentico.Content.Web.Mvc

Renders a widget nested inside another widget. Serves as an alternative to the HtmlHelper.Kentico().RenderNestedWidget extension method. See Extending widgets.

XML
@addTagHelper Kentico.Content.Web.Mvc.NestedWidgetTagHelper, Kentico.Content.Web.Mvc

@* In this example, the extended widget uses an extended FormWidgetProperties class *@
@model ComponentViewModel<ExtendedFormWidgetProperties>
@* Renders the system's default Form widget as the nested widget *@
<nested-widget widget-type-identifier="@SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER" widget-properties="Model.Properties" />

Tag Helpers – Form builder

Form zone

Fully qualified name: Kentico.Content.Web.Mvc.FormZoneTagHelper

Assembly name: Kentico.Content.Web.Mvc

Marks a location where form components can be placed within a form section. Serves as an alternative to the HtmlHelper.Kentico().FormZoneAsync extension method.

XML
@addTagHelper Kentico.Content.Web.Mvc.FormZoneTagHelper, Kentico.Content.Web.Mvc

<form-zone />

The helper also has the following optional attributes:- zone-name – identifier of the zone used when changing the type of the zone in the page builder.

XML
<form-zone zone-name="main-zone" />

Tag Helpers – Caching

Cache dependency

Fully qualified name: Kentico.Web.Mvc.Caching.CacheDependencyTagHelper

Assembly name: Kentico.Web.Mvc

Allows for specification of dependency cache keys within the Cache tag helper⁠ (opens in a new tab) element. See Caching page output in ASP.NET Core applications and Setting cache dependencies.

The helper has the following attributes:

  • cache-keys – an array of cache dependency dummy keys.
  • enabled – indicates whether the dependencies get injected. Enabled by default.
XML
@addTagHelper Kentico.Web.Mvc.Caching.CacheDependencyTagHelper, Kentico.Web.Mvc

@{
    var userCacheKeys = new[] { "cms.user|all" };

    var enabled = false;
}
<cache enabled="@enabled">
    @* Clears the cached data whenever a user object is modified *@
    <cache-dependency cache-keys="@userCacheKeys" enabled="@enabled" />

    Time: @DateTime.Now
</cache>

On this page

  • Adding Tag Helpers to views
  • Tag Helpers – Page builder
    • Page builder scripts
    • Page builder styles
    • Editable area
    • Widget zone
    • Page data
    • Component properties data
    • Stand-alone widget
    • Nested widget
  • Tag Helpers – Form builder
    • Form zone
  • Tag Helpers – Caching
    • Cache dependency