A collection of ASP.NET Core TagHelpers for table operations, image handling, and file size formatting.
$ dotnet add package RGHB.TagHelpersA collection of ASP.NET Core TagHelpers designed to simplify common tasks in web applications, such as table row operations, image handling, file size formatting, and pagination.
Add the NuGet package to your project:
dotnet add package RGHB.TagHelpers --version 1.1.0
Register the tag helpers in your _ViewImports.cshtml:
@addTagHelper *, RGHB.TagHelpers
Ensure you have Bootstrap and Phosphor Icons (or equivalent CSS classes) included in your project for styling and icons.
rghb-delete-table-rowGenerates a delete button that triggers a Bootstrap modal for confirming deletion.
Attributes:
url: The URL for the delete action.id: The ID of the item to delete.Example:
<rghb-delete-table-row url="/Controller/Delete" id="123"></rghb-delete-table-row>
Output:
A button with a trash icon that opens a modal with data-id and data-action attributes.
Note: You need to include a Bootstrap modal with the ID deleteConfirmationModal and handle the delete action via JavaScript.
rghb-edit-table-rowGenerates an edit link with an icon for a table row.
Attributes:
url: The URL for the edit action.Example:
<rghb-edit-table-row url="/Controller/Edit/123"></rghb-edit-table-row>
Output: An anchor tag with a pencil icon and a localized "Edit" title.
rghb-IsCheckedDisplays a check or cross icon based on a boolean value.
Attributes:
is-checked: The boolean value to display (true for check, false for cross).css-class: The CSS class for the icon.Example:
<rghb-IsChecked is-checked="true" css-class="ph ph-check"></rghb-IsChecked>
Output: A check icon for or a cross icon for , styled with the provided CSS class.
truefalseimg (with fallback-src)Handles image loading with a fallback source if the original image is unavailable.
Attributes:
src: The source path of the image.fallback-src: The fallback image source path.Example:
<img src="~/images/photo.jpg" fallback-src="~/images/default.jpg" />
Output:
An img tag with the src set to the original image if it exists, or the fallback image otherwise.
rghb-filesizeFormats a file size in KB or MB for display.
Attributes:
size: The file size in kilobytes (KB).Example:
<rghb-filesize size="2048"></rghb-filesize>
Output:
A span tag displaying "2 MB" (or "2048 KB" if less than 1024 KB).
rghb-table-pagingGenerates a pagination control for a table with previous/next links and page information.
Attributes:
current-page: The current page number.total-pages: The total number of pages.total-item: The total number of items.paging-action: The action name for paging links.paging-controller: The controller name for paging links.paging-area: The area name for paging links (optional).Example:
<rghb-table-paging current-page="1" total-pages="5" total-item="50" paging-action="Index" paging-controller="Home" paging-area=""></rghb-table-paging>
Output: A Bootstrap pagination control with previous/next links and a summary of the current page and total items.
This project is licensed under the MIT License.