TagHelpers
This part contains number of tag-helpers that could be used in many different situations.
Contents
AnchorMatchTagHelper - add needed css-classes to target anchor depending on current url;
AppendClassTagHelper - add needed css-classes to target element dynamically regarding provided condition;
PageInfoTagHelper - organize info-text about items lists pagination;
PageSizeTagHelper - create dropdown with possible number of pages on list;
PaginationTagHelper - create pagination controls simply;
SortTagHelper - organize items list sorting;
TagHelperOutputExtensions - some extension methods for
TagHelperOutput
class.
AnchorMatchTagHelper
An AnchorTagHelper
implementation that adds CSS class to target <a>
element when current Area, Controller and Action RouteData
values correspond to specified ones.
Property name | Property type | Description |
---|---|---|
MatchClass |
| A CSS class to add to html element. |
Each of links above will be highlighted by adding active
css class only when user currently located on corresponding page (which means required area, controller and action).
AppendClassTagHelper
A TagHelper
implementation that adds CSS class to target element when "asp-append-if" is set to true
.
Property name | Property type | Description |
---|---|---|
Append |
| A condition that determines whenever class should or shouldn't be added. |
Class |
| A CSS class to add to html element. |
PageInfoTagHelper
A TagHelper
implementation allowing to organize info-text about pagination in a simple manner.
Property name | Property type | Description |
---|---|---|
Options |
| Options to be used while creating info-text about pagination. |
The PageInfoOptions
are:
Property name | Property type | Description |
---|---|---|
PagedList |
| An instance of |
Format |
| Info-text format string. It uses string-interpolation with following 5 parameters: 0 - page number, 1 - total pages, 2 - first item on page, 3 - last item on page, 4 - total items. |
After rendering it will give:
PageSizeTagHelper
A TagHelper
implementation that creates dropdown menu for page size changing.
Property name | Property type | Description |
---|---|---|
Options |
| Options influencing appearance of dropdown menu. |
The PageSizeOptions
are:
Property name | Property type | Description |
---|---|---|
AllItemsFormat |
| A text to show for menu element corresponding to visualizing of all items. |
DropdownMenuAlign |
| Align of dropdown menu elements. |
ContainerCssClass |
| Css class for controls container. |
DropdownCssClass |
| Css class for div container of dropdown defining count of elements on page. |
DropdownToggleCssClass |
| Css class for button of dropdown defining count of elements on page. |
DropdownToggleAttribute |
| Name of html-attribute to identify a dropdown. |
ItemsPerPage |
| List of possible values of page sizes. |
PageSizeRouteParamName |
| Name of route parameter containing the page size value. |
DefaultPageSize |
| Page size by default. |
After rendering it will give:
PaginationTagHelper
A TagHelper
implementation creating an array of buttons and other elements forming UI pagination controls without boring manual work.
Property name | Property type | Description |
---|---|---|
Options |
| Options influencing appearance of UI pagination controls. |
The PaginationOptions
are:
Property name | Property type | Description |
---|---|---|
PagedList |
| An instance of |
PageUrlGenerator |
| Factory intended for generation of urls to different pages. |
Display |
| Determines display mode for all pagination controls. |
DisplayLinkToFirstPage, etc. |
| Determines display mode for different buttons. |
DisplayLinkToIndividualPages |
| Determines whenever buttons to specific pages should be displayed or not. Default value is |
MaximumPageNumbersToDisplay |
| Maximum count of buttons with page numbers to display. Default value is 3. |
DisplayEllipsesWhenNotShowingAllPageNumbers |
| Determines whenever to display ellipses between sets of buttons or not. |
EllipsesFormat |
| Format of ellipsis displayed between sets of page buttons. Default value is " |
LinkToFirstPageFormat, etc. |
| Format of buttons redirecting to first and other pages respectively. Default values are |
FunctionToDisplayEachPageNumber |
| Allows to transform output of page numbers allowing to build for example something like "First", "Second", etc. |
DelimiterBetweenPageNumbers |
| Delimiter strings to place between page numbers. |
FunctionToTransformEachPageLink |
| Method allowing to format HTML for |
PageNumberRouteParamName |
| Route parameter name for page number. Default value is |
After rendering it will give:
SortTagHelper
A TagHelper
implementation creating sorting controls for UI.
Property name | Property type | Description |
---|---|---|
Sort |
| Name of Model field to sort by. When value of field equals |
DefaultSort |
| Value of field to sort by, taken from query (url). For example |
DefaultOrder |
| Sort order to be used, taken from query (url). For example |
Options |
| Options influencing appearance of sorting controls. |
The SortOptions
are:
Property name | Property type | Description |
---|---|---|
LinkCssCLass |
| Css class for links. Default value is |
ActiveCssClass |
| Css class for active element. Default value is |
SortRouteParamName |
| Name of route parameter containing name of field to sort by. Default value is |
OrderRouteParamName |
| Route parameter name for sort order. Default value is |
After rendering it will give:
TagHelperOutputExtensions
Method name | Return type | Description |
---|---|---|
AddClass |
| Adds specified class to TagHelper output using using built-in instance of the |
RemoveClass |
| Removes specified class from TagHelper output using built-in instance of the |
Last updated