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.
MatchClass
string
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
.
Append
bool
A condition that determines whenever class should or shouldn't be added.
Class
bool
A CSS class to add to html element.
PageInfoTagHelper
A TagHelper
implementation allowing to organize info-text about pagination in a simple manner.
Options
PageInfoOptions
Options to be used while creating info-text about pagination.
The PageInfoOptions
are:
PagedList
IPagedList
An instance of Structr.Collections.IPagedList
to get information about pagination from.
Format
string
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.
Options
PageSizeOptions
Options influencing appearance of dropdown menu.
The PageSizeOptions
are:
AllItemsFormat
string
A text to show for menu element corresponding to visualizing of all items.
DropdownMenuAlign
PageSizeDropdownMenuAlign
Align of dropdown menu elements.
ContainerCssClass
string
Css class for controls container.
DropdownCssClass
string
Css class for div container of dropdown defining count of elements on page.
DropdownToggleCssClass
string
Css class for button of dropdown defining count of elements on page.
DropdownToggleAttribute
string
Name of html-attribute to identify a dropdown.
ItemsPerPage
IEnumerable<int>
List of possible values of page sizes.
PageSizeRouteParamName
string
Name of route parameter containing the page size value.
DefaultPageSize
int
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.
Options
PaginationOptions
Options influencing appearance of UI pagination controls.
The PaginationOptions
are:
PagedList
IPagedList
An instance of Structr.Collections.IPagedList
to get information about pagination from.
PageUrlGenerator
Func<int, string>
Factory intended for generation of urls to different pages.
Display
PaginationDisplayMode
Determines display mode for all pagination controls.
DisplayLinkToFirstPage, etc.
PaginationDisplayMode
Determines display mode for different buttons.
DisplayLinkToIndividualPages
bool
Determines whenever buttons to specific pages should be displayed or not. Default value is true
.
MaximumPageNumbersToDisplay
bool
Maximum count of buttons with page numbers to display. Default value is 3.
DisplayEllipsesWhenNotShowingAllPageNumbers
bool
Determines whenever to display ellipses between sets of buttons or not.
EllipsesFormat
string
Format of ellipsis displayed between sets of page buttons. Default value is "...
".
LinkToFirstPageFormat, etc.
string
Format of buttons redirecting to first and other pages respectively. Default values are ««
, «
, etc.
FunctionToDisplayEachPageNumber
Func<int, string>
Allows to transform output of page numbers allowing to build for example something like "First", "Second", etc.
DelimiterBetweenPageNumbers
string
Delimiter strings to place between page numbers.
FunctionToTransformEachPageLink
string
Method allowing to format HTML for li
and a
inside of paging controls, using TagBuilders.
PageNumberRouteParamName
string
Route parameter name for page number. Default value is page
.
After rendering it will give:
SortTagHelper
A TagHelper
implementation creating sorting controls for UI.
Sort
string
Name of Model field to sort by. When value of field equals DefaultSort
then sorting will be performed.
DefaultSort
string
Value of field to sort by, taken from query (url). For example @Model.Query.Sort
.
DefaultOrder
SortOrder?
Sort order to be used, taken from query (url). For example @Model.Query.Order
.
Options
SortOptions
Options influencing appearance of sorting controls.
The SortOptions
are:
LinkCssCLass
string
Css class for links. Default value is sort
.
ActiveCssClass
string
Css class for active element. Default value is active
.
SortRouteParamName
string
Name of route parameter containing name of field to sort by. Default value is sort
.
OrderRouteParamName
string
Route parameter name for sort order. Default value is order
.
After rendering it will give:
TagHelperOutputExtensions
AddClass
void
Adds specified class to TagHelper output using using built-in instance of the System.Text.Encodings.Web.HtmlEncoder
.
RemoveClass
void
Removes specified class from TagHelper output using built-in instance of the System.Text.Encodings.Web.HtmlEncoder
.
Last updated